make tests green
This commit is contained in:
@@ -13,7 +13,7 @@ exports[`Subtitle renders correctly 1`] = `
|
||||
className="outline-none w-full text-xs sm:text-lg sm:w-1/2 border-t-0 border-l-0 border-r-0 border solid border-gray-900 py-1 px-2 focus:border-blue-700"
|
||||
id="subtitle"
|
||||
onChange={[Function]}
|
||||
value="A frontend developer"
|
||||
value="subtitle"
|
||||
/>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -5,11 +5,22 @@ import toJson from "enzyme-to-json"
|
||||
import Subtitle from "../subtitle"
|
||||
|
||||
describe("Subtitle", () => {
|
||||
const component = shallow(
|
||||
<Subtitle data={{ subtitle: "A frontend developer" }} />
|
||||
)
|
||||
const mockEvent = { target: { value: "This is a mock event" } }
|
||||
const props = {
|
||||
data: {
|
||||
subtitle: "subtitle",
|
||||
},
|
||||
handleDataChange: jest.fn().mockReturnValue({}),
|
||||
}
|
||||
|
||||
const component = shallow(<Subtitle {...props} />)
|
||||
|
||||
it("renders correctly", () => {
|
||||
expect(toJson(component)).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it("calls onChange", () => {
|
||||
component.find("input").at(0).simulate("change", mockEvent)
|
||||
expect(props.handleDataChange).toBeCalledWith("subtitle", mockEvent)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user