2018-11-05 15:26:18 +00:00
|
|
|
import { shallowMount, mount } from '@vue/test-utils';
|
2018-11-14 14:00:01 +00:00
|
|
|
import Checkbox from '@/components/common/Checkbox.vue';
|
2018-11-05 15:26:18 +00:00
|
|
|
|
|
|
|
describe('Checkbox.vue', () => {
|
|
|
|
|
|
|
|
it('renders correctly', () => {
|
|
|
|
|
|
|
|
const wrapper = shallowMount(Checkbox);
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emit setData on change correctly', () => {
|
|
|
|
|
|
|
|
const wrapper = mount(Checkbox);
|
|
|
|
|
|
|
|
wrapper.find("input").trigger('change');
|
|
|
|
wrapper.find("input").trigger('change');
|
|
|
|
|
|
|
|
expect(wrapper.emitted("setData").length).toEqual(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits with data correctly', () => {
|
|
|
|
|
|
|
|
const wrapper = mount(Checkbox);
|
|
|
|
|
|
|
|
wrapper.vm.$emit('setData', true);
|
|
|
|
|
|
|
|
expect(wrapper.emitted("setData")[0][0]).toEqual(true);
|
|
|
|
});
|
2018-11-26 15:57:11 +00:00
|
|
|
|
|
|
|
it('renders correctly with error', () => {
|
|
|
|
|
|
|
|
const wrapper = shallowMount(Checkbox, {
|
|
|
|
propsData: { isCheckboxError: true }
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-11-05 15:26:18 +00:00
|
|
|
});
|