2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
import Checkbox from '@/components/common/VCheckbox.vue';
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import { mount, shallowMount } from '@vue/test-utils';
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
describe('Checkbox.vue', () => {
|
2019-02-20 13:33:56 +00:00
|
|
|
it('renders correctly', () => {
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = shallowMount(Checkbox);
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
it('emit setData on change correctly', () => {
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = mount(Checkbox);
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
wrapper.find('input').trigger('change');
|
|
|
|
wrapper.find('input').trigger('change');
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper.emitted('setData').length).toEqual(2);
|
|
|
|
});
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
it('emits with data correctly', () => {
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = mount(Checkbox);
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
wrapper.vm.$emit('setData', true);
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper.emitted('setData')[0][0]).toEqual(true);
|
|
|
|
});
|
2018-11-26 15:57:11 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
it('renders correctly with error', () => {
|
2018-11-26 15:57:11 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = shallowMount(Checkbox, {
|
2019-09-13 15:58:18 +01:00
|
|
|
propsData: {isCheckboxError: true},
|
2019-02-20 13:33:56 +00:00
|
|
|
});
|
2018-11-26 15:57:11 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-12-18 14:43:23 +00:00
|
|
|
});
|