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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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', () => {
2022-06-21 17:19:12 +05:30
expect(vm.find('.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', () => {
2022-06-21 17:19:12 +05:30
expect(vm.find('.max-issue-size').text()).toEqual(String(maxIssueCount));
2020-01-01 13:55:28 +05:30
});
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', () => {
2022-06-21 17:19:12 +05:30
expect(vm.find('.max-issue-size').text()).toEqual(String(maxIssueCount));
2020-01-01 13:55:28 +05:30
});
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
});
});
});