Welcome to mirror list, hosted at ThFree Co, Russian Federation.

blob_fork_suggestion_spec.js « blob « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d0d64d75957c71e95260af7aa37ad44b9c59e6b1 (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
import BlobForkSuggestion from '~/blob/blob_fork_suggestion';

describe('BlobForkSuggestion', () => {
  let blobForkSuggestion;

  const openButtons = [document.createElement('div')];
  const forkButtons = [document.createElement('a')];
  const cancelButtons = [document.createElement('div')];
  const suggestionSections = [document.createElement('div')];
  const actionTextPieces = [document.createElement('div')];

  beforeEach(() => {
    blobForkSuggestion = new BlobForkSuggestion({
      openButtons,
      forkButtons,
      cancelButtons,
      suggestionSections,
      actionTextPieces,
    });
  });

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

  it('showSuggestionSection', () => {
    blobForkSuggestion.showSuggestionSection('/foo', 'foo');
    expect(suggestionSections[0].classList.contains('hidden')).toEqual(false);
    expect(forkButtons[0].getAttribute('href')).toEqual('/foo');
    expect(actionTextPieces[0].textContent).toEqual('foo');
  });

  it('hideSuggestionSection', () => {
    blobForkSuggestion.hideSuggestionSection();
    expect(suggestionSections[0].classList.contains('hidden')).toEqual(true);
  });
});