2017-04-10 20:51:24 +00:00
|
|
|
import BlobForkSuggestion from '~/blob/blob_fork_suggestion';
|
|
|
|
|
|
|
|
describe('BlobForkSuggestion', () => {
|
|
|
|
let blobForkSuggestion;
|
|
|
|
|
2017-04-21 18:56:27 +00:00
|
|
|
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');
|
2017-04-10 20:51:24 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
blobForkSuggestion = new BlobForkSuggestion({
|
2017-04-21 18:56:27 +00:00
|
|
|
openButtons: openButton,
|
|
|
|
forkButtons: forkButton,
|
|
|
|
cancelButtons: cancelButton,
|
|
|
|
suggestionSections: suggestionSection,
|
|
|
|
actionTextPieces: actionTextPiece,
|
|
|
|
})
|
|
|
|
.init();
|
2017-04-10 20:51:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
blobForkSuggestion.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('showSuggestionSection', () => {
|
|
|
|
blobForkSuggestion.showSuggestionSection('/foo', 'foo');
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-04-21 18:56:27 +00:00
|
|
|
expect(suggestionSection.classList.contains('hidden')).toEqual(false);
|
|
|
|
expect(forkButton.getAttribute('href')).toEqual('/foo');
|
|
|
|
expect(actionTextPiece.textContent).toEqual('foo');
|
2017-04-10 20:51:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('hideSuggestionSection', () => {
|
|
|
|
blobForkSuggestion.hideSuggestionSection();
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-04-21 18:56:27 +00:00
|
|
|
expect(suggestionSection.classList.contains('hidden')).toEqual(true);
|
2017-04-10 20:51:24 +00:00
|
|
|
});
|
|
|
|
});
|