Created
April 27, 2022 20:49
-
-
Save tanner-west/5a3d1ae3737adf87fbd5add3da01120e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React from 'react'; | |
import Enzyme, {shallow} from 'enzyme'; | |
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; | |
import Name from './Name'; | |
Enzyme.configure({adapter: new Adapter()}); | |
describe('<Name />', () => { | |
let wrapper: any; | |
const createWrapper = () => { | |
wrapper = shallow(<Name />); | |
}; | |
beforeEach(() => createWrapper()); | |
it("should render 'get started' message", () => { | |
const messageWrapper = wrapper.findWhere( | |
(n: any) => n.text() === 'Please type your name to get started', | |
); | |
expect(messageWrapper).toHaveLength(1); | |
}); | |
it("should render 'Your name is: Ray Bradbury'", () => { | |
const nameInput = wrapper.findWhere( | |
(node: any) => node.prop('testID') === 'name-input', | |
); | |
nameInput.props().onChangeText('Ray Bradbury'); | |
const nameWrapper = wrapper.findWhere( | |
(n: any) => n.text() === 'Your name is: Ray Bradbury', | |
); | |
expect(nameWrapper).toHaveLength(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment