debian-mirror-gitlab/spec/frontend/blob/blob_fork_suggestion_spec.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import BlobForkSuggestion from '~/blob/blob_fork_suggestion';
describe('BlobForkSuggestion', () => {
let blobForkSuggestion;
const openButton = document.createElement('div');
const forkButton = document.createElement('a');
const cancelButton = document.createElement('div');
const suggestionSection = document.createElement('div');
const actionTextPiece = document.createElement('div');
beforeEach(() => {
blobForkSuggestion = new BlobForkSuggestion({
openButtons: openButton,
forkButtons: forkButton,
cancelButtons: cancelButton,
suggestionSections: suggestionSection,
actionTextPieces: actionTextPiece,
2018-12-13 13:39:08 +05:30
}).init();
2017-08-17 22:00:37 +05:30
});
afterEach(() => {
blobForkSuggestion.destroy();
});
it('showSuggestionSection', () => {
blobForkSuggestion.showSuggestionSection('/foo', 'foo');
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(suggestionSection.classList.contains('hidden')).toEqual(false);
expect(forkButton.getAttribute('href')).toEqual('/foo');
expect(actionTextPiece.textContent).toEqual('foo');
});
it('hideSuggestionSection', () => {
blobForkSuggestion.hideSuggestionSection();
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(suggestionSection.classList.contains('hidden')).toEqual(true);
});
});