make tags deleteable
seperate sidebar for each different category page
This commit is contained in:
@ -4,7 +4,7 @@ import {CategoryView} from './CategoryView';
|
||||
|
||||
describe('<CategoryView/>', function () {
|
||||
function instance() {
|
||||
return shallow(<CategoryView match={{params: {id: 10}}}/>);
|
||||
return shallow(<CategoryView match={{params: {id: 10}}} history={{push: jest.fn()}}/>);
|
||||
}
|
||||
|
||||
it('renders without crashing ', function () {
|
||||
@ -21,4 +21,54 @@ describe('<CategoryView/>', function () {
|
||||
wrapper.find('button').simulate('click');
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('test delete of tag', function () {
|
||||
const wrapper = instance();
|
||||
callAPIMock({result: 'success'});
|
||||
|
||||
// simulate button click
|
||||
wrapper.find('Button').props().onClick();
|
||||
|
||||
expect(wrapper.instance().props.history.push).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('test delete of non empty tag', function () {
|
||||
const wrapper = instance();
|
||||
callAPIMock({result: 'not empty tag'});
|
||||
|
||||
// simulate button click
|
||||
wrapper.find('Button').props().onClick();
|
||||
|
||||
// expect SubmitPopup showing
|
||||
expect(wrapper.find('SubmitPopup')).toHaveLength(1);
|
||||
|
||||
// mock deleteTag function
|
||||
wrapper.instance().deleteTag = jest.fn((v) => {});
|
||||
|
||||
// simulate submit
|
||||
wrapper.find('SubmitPopup').props().submit();
|
||||
|
||||
// expect deleteTag function to have been called with force parameter
|
||||
expect(wrapper.instance().deleteTag).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
it('test cancel of ', function () {
|
||||
const wrapper = instance();
|
||||
callAPIMock({result: 'not empty tag'});
|
||||
|
||||
// simulate button click
|
||||
wrapper.find('Button').props().onClick();
|
||||
|
||||
// expect SubmitPopup showing
|
||||
expect(wrapper.find('SubmitPopup')).toHaveLength(1);
|
||||
|
||||
// mock deleteTag function
|
||||
wrapper.instance().deleteTag = jest.fn((v) => {});
|
||||
|
||||
// simulate submit
|
||||
wrapper.find('SubmitPopup').props().onHide();
|
||||
|
||||
// expect deleteTag function to have been called with force parameter
|
||||
expect(wrapper.instance().deleteTag).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user