Skip to content

Commit

Permalink
test: test for onClick
Browse files Browse the repository at this point in the history
  • Loading branch information
dalbitresb12 committed Jun 12, 2020
1 parent dcec589 commit 8095e92
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/obfuscate.test.js
Expand Up @@ -42,7 +42,7 @@ describe('obfuscate', () => {
wrapper.simulate('click', { preventDefault: () => {} });
expect(global.window.location.href).toEqual(
`mailto:${testEmail}?${Object.keys(headers)
.map(key => `${key}=${encodeURIComponent(headers[key])}`)
.map((key) => `${key}=${encodeURIComponent(headers[key])}`)
.join('&')}`
);
});
Expand Down Expand Up @@ -113,13 +113,14 @@ describe('obfuscate', () => {
expect(wrapper.prop('onClick')).toBeUndefined();
});

test('calls supplied onClick method before changing location', () => {
test('calls supplied onClick method', () => {
const onClick = jest.fn();
const wrapper = shallow(<Obfuscate email={testEmail} onClick={onClick} />);

wrapper.simulate('mouseover');
wrapper.simulate('click', { preventDefault: () => {} });
expect(onClick).toHaveBeenCalled();
expect(global.window.location.href).toEqual(`mailto:${testEmail}`);
expect(wrapper.prop('href')).toEqual(`mailto:${testEmail}`);
});

test('unobfuscates href when user mouses over element', () => {
Expand Down

0 comments on commit 8095e92

Please sign in to comment.