gitlab-org--gitlab-foss/spec/frontend/commit_merge_requests_spec.js

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

70 lines
2.3 KiB
JavaScript
Raw Normal View History

import * as CommitMergeRequests from '~/commit_merge_requests';
describe('CommitMergeRequests', () => {
describe('createContent', () => {
it('should return created content', () => {
2018-10-17 03:13:26 -04:00
const content1 = CommitMergeRequests.createContent([
{ iid: 1, path: '/path1', title: 'foo' },
{ iid: 2, path: '/path2', title: 'baz' },
])[0];
2018-10-09 14:03:09 -04:00
expect(content1.tagName).toEqual('SPAN');
expect(content1.childElementCount).toEqual(4);
const content2 = CommitMergeRequests.createContent([])[0];
2018-10-09 14:03:09 -04:00
expect(content2.tagName).toEqual('SPAN');
expect(content2.childElementCount).toEqual(0);
expect(content2.innerText).toEqual('No related merge requests found');
});
});
describe('getHeaderText', () => {
it('should return header text', () => {
expect(CommitMergeRequests.getHeaderText(0, 1)).toEqual('1 merge request');
expect(CommitMergeRequests.getHeaderText(0, 2)).toEqual('2 merge requests');
expect(CommitMergeRequests.getHeaderText(1, 1)).toEqual(',');
expect(CommitMergeRequests.getHeaderText(1, 2)).toEqual(',');
});
});
describe('createHeader', () => {
it('should return created header', () => {
const header = CommitMergeRequests.createHeader(0, 1)[0];
2018-10-09 14:03:09 -04:00
expect(header.tagName).toEqual('SPAN');
expect(header.innerText).toEqual('1 merge request');
});
});
describe('createItem', () => {
it('should return created item', () => {
const item = CommitMergeRequests.createItem({ iid: 1, path: '/path', title: 'foo' })[0];
2018-10-09 14:03:09 -04:00
expect(item.tagName).toEqual('SPAN');
expect(item.childElementCount).toEqual(2);
expect(item.children[0].tagName).toEqual('A');
expect(item.children[1].tagName).toEqual('SPAN');
});
});
describe('createLink', () => {
it('should return created link', () => {
const link = CommitMergeRequests.createLink({ iid: 1, path: '/path', title: 'foo' })[0];
2018-10-09 14:03:09 -04:00
expect(link.tagName).toEqual('A');
expect(link.href).toMatch(/\/path$/);
expect(link.innerText).toEqual('!1');
});
});
describe('createTitle', () => {
it('should return created title', () => {
const title = CommitMergeRequests.createTitle({ iid: 1, path: '/path', title: 'foo' })[0];
2018-10-09 14:03:09 -04:00
expect(title.tagName).toEqual('SPAN');
expect(title.innerText).toEqual('foo');
});
});
});