debian-mirror-gitlab/spec/frontend/boards/components/item_count_spec.js

86 lines
2.2 KiB
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { shallowMount } from '@vue/test-utils';
2021-04-17 20:07:23 +05:30
import IssueCount from '~/boards/components/item_count.vue';
2020-01-01 13:55:28 +05:30
describe('IssueCount', () => {
let vm;
let maxIssueCount;
2021-04-17 20:07:23 +05:30
let itemsSize;
2020-01-01 13:55:28 +05:30
2021-03-08 18:12:59 +05:30
const createComponent = (props) => {
2020-01-01 13:55:28 +05:30
vm = shallowMount(IssueCount, { propsData: props });
};
afterEach(() => {
maxIssueCount = 0;
2021-04-17 20:07:23 +05:30
itemsSize = 0;
2020-01-01 13:55:28 +05:30
if (vm) vm.destroy();
});
describe('when maxIssueCount is zero', () => {
beforeEach(() => {
2021-04-17 20:07:23 +05:30
itemsSize = 3;
2020-01-01 13:55:28 +05:30
2021-04-17 20:07:23 +05:30
createComponent({ maxIssueCount: 0, itemsSize });
2020-01-01 13:55:28 +05:30
});
it('contains issueSize in the template', () => {
2021-04-17 20:07:23 +05:30
expect(vm.find('[data-testid="board-items-count"]').text()).toEqual(String(itemsSize));
2020-01-01 13:55:28 +05:30
});
it('does not contains maxIssueCount in the template', () => {
2020-11-24 15:15:51 +05:30
expect(vm.find('.js-max-issue-size').exists()).toBe(false);
2020-01-01 13:55:28 +05:30
});
});
describe('when maxIssueCount is greater than zero', () => {
beforeEach(() => {
maxIssueCount = 2;
2021-04-17 20:07:23 +05:30
itemsSize = 1;
2020-01-01 13:55:28 +05:30
2021-04-17 20:07:23 +05:30
createComponent({ maxIssueCount, itemsSize });
2020-01-01 13:55:28 +05:30
});
afterEach(() => {
vm.destroy();
});
it('contains issueSize in the template', () => {
2021-04-17 20:07:23 +05:30
expect(vm.find('[data-testid="board-items-count"]').text()).toEqual(String(itemsSize));
2020-01-01 13:55:28 +05:30
});
it('contains maxIssueCount in the template', () => {
expect(vm.find('.js-max-issue-size').text()).toEqual(String(maxIssueCount));
});
it('does not have text-danger class when issueSize is less than maxIssueCount', () => {
expect(vm.classes('.text-danger')).toBe(false);
});
});
describe('when issueSize is greater than maxIssueCount', () => {
beforeEach(() => {
2021-04-17 20:07:23 +05:30
itemsSize = 3;
2020-01-01 13:55:28 +05:30
maxIssueCount = 2;
2021-04-17 20:07:23 +05:30
createComponent({ maxIssueCount, itemsSize });
2020-01-01 13:55:28 +05:30
});
afterEach(() => {
vm.destroy();
});
it('contains issueSize in the template', () => {
2021-04-17 20:07:23 +05:30
expect(vm.find('[data-testid="board-items-count"]').text()).toEqual(String(itemsSize));
2020-01-01 13:55:28 +05:30
});
it('contains maxIssueCount in the template', () => {
expect(vm.find('.js-max-issue-size').text()).toEqual(String(maxIssueCount));
});
it('has text-danger class', () => {
2021-04-17 20:07:23 +05:30
expect(vm.find('.text-danger').text()).toEqual(String(itemsSize));
2020-01-01 13:55:28 +05:30
});
});
});