2020-03-13 15:44:24 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
2020-01-01 13:55:28 +05:30
|
|
|
import { GlLink } from '@gitlab/ui';
|
|
|
|
import { truncateSha } from '~/lib/utils/text_utility';
|
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2020-03-13 15:44:24 +05:30
|
|
|
import { release } from '../mock_data';
|
|
|
|
import EvidenceBlock from '~/releases/components/evidence_block.vue';
|
2020-01-01 13:55:28 +05:30
|
|
|
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
|
|
|
|
|
|
|
describe('Evidence Block', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const factory = (options = {}) => {
|
2020-03-13 15:44:24 +05:30
|
|
|
wrapper = mount(EvidenceBlock, {
|
2020-01-01 13:55:28 +05:30
|
|
|
...options,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
factory({
|
|
|
|
propsData: {
|
|
|
|
release,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the evidence icon', () => {
|
|
|
|
expect(wrapper.find(Icon).props('name')).toBe('review-list');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the title for the dowload link', () => {
|
|
|
|
expect(wrapper.find(GlLink).text()).toBe(`${release.tag_name}-evidence.json`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the correct hover text for the download', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(wrapper.find(GlLink).attributes('title')).toBe('Download evidence JSON');
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the correct file link for download', () => {
|
|
|
|
expect(wrapper.find(GlLink).attributes().download).toBe(`${release.tag_name}-evidence.json`);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('sha text', () => {
|
|
|
|
it('renders the short sha initially', () => {
|
|
|
|
expect(wrapper.find('.js-short').text()).toBe(truncateSha(release.evidence_sha));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the long sha after expansion', () => {
|
|
|
|
wrapper.find('.js-text-expander-prepend').trigger('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.find('.js-expanded').text()).toBe(release.evidence_sha);
|
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('copy to clipboard button', () => {
|
|
|
|
it('renders button', () => {
|
|
|
|
expect(wrapper.find(ClipboardButton).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the correct hover text', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(wrapper.find(ClipboardButton).attributes('title')).toBe('Copy commit SHA');
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('copies the sha', () => {
|
|
|
|
expect(wrapper.find(ClipboardButton).attributes('data-clipboard-text')).toBe(
|
|
|
|
release.evidence_sha,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|