-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade To React 16 #18
Conversation
As a side effect, this commit also addresses the security vulnerabilities in development environment (from using Karma).
... but still support the previous version of React.
let wrapper; | ||
let inputField; | ||
const handleChange = jest.fn(); | ||
const onDropdownSelect = jest.fn(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one issue of having a global mocked function is it will preserve state across tests, for example this will pass:
const foo = jest.fn();
it('foo', () => {
foo();
expect(foo).toHaveBeenCalled();
});
it('bar', () => {
expect(foo).toHaveBeenCalled();
});
a beforeEach solution might be better going forward:
let wrapper;
let inputField;
let handleChange;
let onDropdownSelect;
beforeEach(() => {
handleChange = jest.fn();
onDropdownSelect = jest.fn();
wrapper = mount(
<LocationAutocomplete
value='some value'
onChange={handleChange}
onDropdownSelect={onDropdownSelect}
googleAPIKey='someKey'
/>
);
inputField = wrapper.find('input');
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albertstill in that example you could also just do beforeEach(() => jest.resetAllMocks());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work thanks for doing this mate
#12 #15