summaryrefslogtreecommitdiff
path: root/spec/javascripts/blob/blob_fork_suggestion_spec.js
blob: 9b81b7e6f92165db6c79b876c53d118d4520351d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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,
    }).init();
  });

  afterEach(() => {
    blobForkSuggestion.destroy();
  });

  it('showSuggestionSection', () => {
    blobForkSuggestion.showSuggestionSection('/foo', 'foo');

    expect(suggestionSection.classList.contains('hidden')).toEqual(false);
    expect(forkButton.getAttribute('href')).toEqual('/foo');
    expect(actionTextPiece.textContent).toEqual('foo');
  });

  it('hideSuggestionSection', () => {
    blobForkSuggestion.hideSuggestionSection();

    expect(suggestionSection.classList.contains('hidden')).toEqual(true);
  });
});