2020-01-01 13:55:28 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import IssueCount from '~/boards/components/issue_count.vue';
|
|
|
|
|
|
|
|
describe('IssueCount', () => {
|
|
|
|
let vm;
|
|
|
|
let maxIssueCount;
|
|
|
|
let issuesSize;
|
|
|
|
|
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;
|
|
|
|
issuesSize = 0;
|
|
|
|
|
|
|
|
if (vm) vm.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when maxIssueCount is zero', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
issuesSize = 3;
|
|
|
|
|
|
|
|
createComponent({ maxIssueCount: 0, issuesSize });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('contains issueSize in the template', () => {
|
|
|
|
expect(vm.find('.js-issue-size').text()).toEqual(String(issuesSize));
|
|
|
|
});
|
|
|
|
|
|
|
|
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;
|
|
|
|
issuesSize = 1;
|
|
|
|
|
|
|
|
createComponent({ maxIssueCount, issuesSize });
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('contains issueSize in the template', () => {
|
|
|
|
expect(vm.find('.js-issue-size').text()).toEqual(String(issuesSize));
|
|
|
|
});
|
|
|
|
|
|
|
|
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(() => {
|
|
|
|
issuesSize = 3;
|
|
|
|
maxIssueCount = 2;
|
|
|
|
|
|
|
|
createComponent({ maxIssueCount, issuesSize });
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('contains issueSize in the template', () => {
|
|
|
|
expect(vm.find('.js-issue-size').text()).toEqual(String(issuesSize));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('contains maxIssueCount in the template', () => {
|
|
|
|
expect(vm.find('.js-max-issue-size').text()).toEqual(String(maxIssueCount));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('has text-danger class', () => {
|
|
|
|
expect(vm.find('.text-danger').text()).toEqual(String(issuesSize));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|