skillbox/client/tests/unit/checkbox.spec.js

46 lines
1.1 KiB
JavaScript

import {createLocalVue, mount} from '@vue/test-utils';
import Checkbox from '@/components/ui/BaseInput';
const localVue = createLocalVue();
describe('Checkbox.vue', () => {
it('should display the provided props', async () => {
const props = {
label: 'Lonely label',
checked: false,
item: null
};
const wrapper = mount(Checkbox, {
propsData: props,
localVue
});
const input = wrapper.find('[data-cy="base-input-input"]');
const label = wrapper.find('[data-cy="base-input-label"]');
expect(input.element.checked).toEqual(props.checked);
expect(label.element.textContent).toEqual(props.label);
});
it.skip('should emit updated value', async () => {
// todo: failed after update from jest@25 to jest@27, probably already at jest@26
const labelText = 'Lonely label';
const item = {name: 'bla'};
const props = {
label: labelText,
checked: false,
item
};
const wrapper = mount(Checkbox, {
propsData: props,
localVue
});
wrapper.element.click();
expect(wrapper.emitted()['input'][0]).toEqual([!props.checked, item]);
});
});