2018-11-18 11:00:15 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import component from '~/reports/components/test_issue_body.vue';
|
|
|
|
import createStore from '~/reports/store';
|
|
|
|
import { mountComponentWithStore } from '../../helpers/vue_mount_component_helper';
|
2019-09-04 21:01:54 +05:30
|
|
|
import { trimText } from '../../helpers/text_helper';
|
2018-11-18 11:00:15 +05:30
|
|
|
import { issue } from '../mock_data/mock_data';
|
|
|
|
|
|
|
|
describe('Test Issue body', () => {
|
|
|
|
let vm;
|
|
|
|
const Component = Vue.extend(component);
|
|
|
|
const store = createStore();
|
|
|
|
|
|
|
|
const commonProps = {
|
|
|
|
issue,
|
|
|
|
status: 'failed',
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('on click', () => {
|
|
|
|
it('calls openModal action', () => {
|
|
|
|
vm = mountComponentWithStore(Component, {
|
|
|
|
store,
|
|
|
|
props: commonProps,
|
|
|
|
});
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
jest.spyOn(vm, 'openModal').mockImplementation(() => {});
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
vm.$el.querySelector('button').click();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
expect(vm.openModal).toHaveBeenCalledWith({
|
|
|
|
issue: commonProps.issue,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('is new', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponentWithStore(Component, {
|
|
|
|
store,
|
2020-05-24 23:13:21 +05:30
|
|
|
props: { ...commonProps, isNew: true },
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders issue name', () => {
|
|
|
|
expect(vm.$el.textContent).toContain(commonProps.issue.name);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders new badge', () => {
|
|
|
|
expect(trimText(vm.$el.querySelector('.badge').textContent)).toEqual('New');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('not new', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponentWithStore(Component, {
|
|
|
|
store,
|
|
|
|
props: commonProps,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders issue name', () => {
|
|
|
|
expect(vm.$el.textContent).toContain(commonProps.issue.name);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not renders new badge', () => {
|
|
|
|
expect(vm.$el.querySelector('.badge')).toEqual(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|