2021-01-03 14:25:43 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import BoardConfigurationOptions from '~/boards/components/board_configuration_options.vue';
|
|
|
|
|
|
|
|
describe('BoardConfigurationOptions', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const defaultProps = {
|
2021-03-08 18:12:59 +05:30
|
|
|
hideBacklogList: false,
|
|
|
|
hideClosedList: false,
|
2021-03-11 19:13:27 +05:30
|
|
|
readonly: false,
|
2021-01-03 14:25:43 +05:30
|
|
|
};
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const createComponent = (props = {}) => {
|
2021-01-03 14:25:43 +05:30
|
|
|
wrapper = shallowMount(BoardConfigurationOptions, {
|
2021-03-08 18:12:59 +05:30
|
|
|
propsData: { ...defaultProps, ...props },
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const backlogListCheckbox = () => wrapper.find('[data-testid="backlog-list-checkbox"]');
|
|
|
|
const closedListCheckbox = () => wrapper.find('[data-testid="closed-list-checkbox"]');
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
const checkboxAssert = (backlogCheckbox, closedCheckbox) => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(backlogListCheckbox().attributes('checked')).toEqual(
|
2021-01-03 14:25:43 +05:30
|
|
|
backlogCheckbox ? undefined : 'true',
|
|
|
|
);
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(closedListCheckbox().attributes('checked')).toEqual(closedCheckbox ? undefined : 'true');
|
2021-01-03 14:25:43 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
it.each`
|
|
|
|
backlogCheckboxValue | closedCheckboxValue
|
|
|
|
${true} | ${true}
|
|
|
|
${true} | ${false}
|
|
|
|
${false} | ${true}
|
|
|
|
${false} | ${false}
|
|
|
|
`(
|
|
|
|
'renders two checkbox when one is $backlogCheckboxValue and other is $closedCheckboxValue',
|
2021-03-08 18:12:59 +05:30
|
|
|
({ backlogCheckboxValue, closedCheckboxValue }) => {
|
|
|
|
createComponent({
|
2021-01-03 14:25:43 +05:30
|
|
|
hideBacklogList: backlogCheckboxValue,
|
|
|
|
hideClosedList: closedCheckboxValue,
|
|
|
|
});
|
2021-03-08 18:12:59 +05:30
|
|
|
checkboxAssert(backlogCheckboxValue, closedCheckboxValue);
|
2021-01-03 14:25:43 +05:30
|
|
|
},
|
|
|
|
);
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
it('emits a correct value on backlog checkbox change', () => {
|
|
|
|
createComponent();
|
|
|
|
|
|
|
|
backlogListCheckbox().vm.$emit('change');
|
|
|
|
|
|
|
|
expect(wrapper.emitted('update:hideBacklogList')).toEqual([[true]]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits a correct value on closed checkbox change', () => {
|
|
|
|
createComponent();
|
|
|
|
|
|
|
|
closedListCheckbox().vm.$emit('change');
|
|
|
|
|
|
|
|
expect(wrapper.emitted('update:hideClosedList')).toEqual([[true]]);
|
|
|
|
});
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
it('renders checkboxes disabled when user does not have edit rights', () => {
|
|
|
|
createComponent({ readonly: true });
|
|
|
|
|
|
|
|
expect(closedListCheckbox().attributes('disabled')).toBe('true');
|
|
|
|
expect(backlogListCheckbox().attributes('disabled')).toBe('true');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders checkboxes enabled when user has edit rights', () => {
|
|
|
|
createComponent();
|
|
|
|
|
|
|
|
expect(closedListCheckbox().attributes('disabled')).toBeUndefined();
|
|
|
|
expect(backlogListCheckbox().attributes('disabled')).toBeUndefined();
|
|
|
|
});
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|