Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
iris salcedo committed Sep 21, 2021
1 parent fe67fe0 commit 1769171
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/shared/navigationBars/topBar/signOut.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { mount } from 'enzyme';
import { accountLoggedOut } from '@actions';
import { routes } from '@constants';
import SignOut from './signOut';

jest.mock('@actions', () => ({
accountLoggedOut: jest.fn(),
}));

describe('Form', () => {
let wrapper;

const props = {
t: t => t,
history: {
replace: jest.fn(),
},
};

it('should logout properly', () => {
wrapper = mount(<SignOut {...props} />);
wrapper.find('.logoutBtn').at(0).simulate('click');
expect(accountLoggedOut).toHaveBeenCalledTimes(1);
expect(props.history.replace).toHaveBeenCalledWith(routes.login.path);
});
});

0 comments on commit 1769171

Please sign in to comment.