-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add the ability to group routes (#42) * First version of grouping routes * Switched to new calculation of groups and styled them * Added group routing based on togglable state * Updated package-lock * DB - Moved some components around, added some tests and fixed jest running tests * DB - Added more test coverage * Removed useless header x-powered-by (#45) * Improved methods and status codes (#44) * DB - Fixing tests for new routes that were added as part of #44 * Added CHANGELOG * Feature - Add support for adding headers onto responses (#46) * Started to add custom headers * Tmp * #4 - Added the ability to add headers in the routes * Updated CHANGELOG * DB - Format of settings * Updated version
- Loading branch information
Showing
30 changed files
with
1,048 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## [Unreleased] | ||
|
||
- Add the ability to group routes ([JDansercoer](https://github.com/JDansercoer) in [#42](https://github.com/boyney123/mockit/pull/42)) | ||
|
||
- Removed useless header x-powered-by ([webdevium](https://github.com/webdevium) in [#45](https://github.com/boyney123/mockit/pull/45)) | ||
|
||
- Improved methods and status codes ([webdevium](https://github.com/webdevium) in [#44](https://github.com/boyney123/mockit/pull/44)) | ||
|
||
- Add the ability to add custom headers ([boyney123](https://github.com/boyney123) in [#46](https://github.com/boyney123/mockit/pull/46)) | ||
|
||
## 1.0.0 | ||
|
||
Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
jest: function(config) { | ||
config.testMatch.push("<rootDir>/src/**/{spec,test}.{js,jsx,ts,tsx}"); | ||
return config; | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import uuid from "uuid/v4"; | ||
|
||
export default function({ index, data = {}, onBlur = () => {}, onRemove = () => {} } = {}) { | ||
const { id = uuid(), header: initialHeader, value: initialValue } = data; | ||
|
||
const [header, setHeader] = useState(initialHeader); | ||
const [value, setValue] = useState(initialValue); | ||
|
||
const update = (field, inputValue) => { | ||
field === "header" ? setHeader(inputValue) : setValue(inputValue); | ||
}; | ||
|
||
useEffect(() => { | ||
if (header && value) onBlur({ id, header, value }); | ||
}, [header, value]); | ||
|
||
return ( | ||
<div className="columns Header" aria-label="header"> | ||
<div className="control column"> | ||
<input className="input" placeholder="header" value={header} aria-label="header-key" onChange={e => update("header", e.target.value)} /> | ||
</div> | ||
<div className="control column"> | ||
<input className="input" placeholder="value" value={value} aria-label="header-value" onChange={e => update("value", e.target.value)} /> | ||
</div> | ||
<div className="control column is-1 Header__Remove" onClick={() => onRemove(id)}> | ||
<i className="far fa-times-circle" aria-label="remove-header" /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// __tests__/fetch.test.js | ||
import React from "react"; | ||
import { render, fireEvent, cleanup } from "react-testing-library"; | ||
import "jest-dom/extend-expect"; | ||
import HeaderInput from "./"; | ||
|
||
afterEach(cleanup); | ||
|
||
describe("DoubleInput", () => { | ||
describe("renders", () => { | ||
it("two inputs one for the header and one for the value", () => { | ||
const { getByPlaceholderText } = render(<HeaderInput />); | ||
expect(getByPlaceholderText("header")).toBeVisible(); | ||
expect(getByPlaceholderText("value")).toBeVisible(); | ||
}); | ||
|
||
it('two inputs are rendered with the given "header" and "value" data when given to the component', () => { | ||
const { getByPlaceholderText } = render(<HeaderInput data={{ id: 1, header: "Content-Type", value: "application/json" }} />); | ||
expect(getByPlaceholderText("header").value).toEqual("Content-Type"); | ||
expect(getByPlaceholderText("value").value).toEqual("application/json"); | ||
}); | ||
}); | ||
|
||
describe("props: events", () => { | ||
it('onBlur is called when both "header" and "value" have been entered', () => { | ||
const spy = jest.fn(); | ||
const { getByPlaceholderText } = render(<HeaderInput onBlur={spy} />); | ||
fireEvent.change(getByPlaceholderText("header"), { target: { value: "Content-Type" } }); | ||
fireEvent.change(getByPlaceholderText("value"), { target: { value: "application/json" } }); | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('onBlur is not called when "header" value is set but "value" is missing', () => { | ||
const spy = jest.fn(); | ||
const { getByPlaceholderText } = render(<HeaderInput onBlur={spy} />); | ||
fireEvent.change(getByPlaceholderText("header"), { target: { value: "Content-Type" } }); | ||
expect(spy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('onBlur is not called when "value" is set but the "header" value is not', () => { | ||
const spy = jest.fn(); | ||
const { getByPlaceholderText } = render(<HeaderInput onBlur={spy} />); | ||
fireEvent.change(getByPlaceholderText("value"), { target: { value: "application/json" } }); | ||
expect(spy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("onRemove is called with the headers id when the user clicks on the remove icon", () => { | ||
const spy = jest.fn(); | ||
const data = { id: 1, header: "Content-Type", value: "application/json" }; | ||
const { getByLabelText } = render(<HeaderInput data={data} onRemove={spy} />); | ||
fireEvent.click(getByLabelText("remove-header")); | ||
expect(spy).toHaveBeenCalledWith(1); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.