Created
February 20, 2019 10:01
-
-
Save charisschomba/caa6ea390813c36e0c17ad31edc6e0a8 to your computer and use it in GitHub Desktop.
This file contains 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 { mount } from 'enzyme'; | |
import UsersDetails from '../../../components/Users/USersDetails'; | |
import user from '../../../__mocks__/fetchUserData'; | |
const state = { | |
deleteModalOpen: false, | |
selectedUser: null, | |
}; | |
const props = { | |
deleteUser: jest.fn(), | |
}; | |
const wrapper = mount( | |
<UsersDetails users={user.fetchedUsersData} {...props} {...state} />, | |
); | |
describe('<UsersDetails /> ', () => { | |
it('DisplayUsers with necessary data', () => { | |
expect(wrapper.find('Table').length).toBe(1); | |
}); | |
it('test hideDeleteModal', () => { | |
const handleClickSpy = jest.spyOn(wrapper.instance(), 'hideDeleteModal'); | |
wrapper.instance().hideDeleteModal(); | |
expect(handleClickSpy.mock.calls.length).toEqual(1); | |
}); | |
it('test showDeleteModal', () => { | |
const handleClickSpy = jest.spyOn(wrapper.instance(), 'showDeleteModal'); | |
wrapper.instance().showDeleteModal(); | |
expect(handleClickSpy.mock.calls.length).toEqual(1); | |
}); | |
it('test handleDelete', () => { | |
const handleClickSpy = jest.spyOn(wrapper.instance(), 'handleDelete'); | |
wrapper.instance().state = { selectedUser: user.fetchedUsersData }; | |
wrapper.instance().handleDelete(); | |
expect(handleClickSpy.mock.calls.length).toEqual(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment