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

balsamiq_viewer_browser_spec.js « balsamiq « blob « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e06e5c12fc8815aa14dea5f0455d7b7a94d1c4a (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// this file can't be migrated to jest because it relies on the browser to perform integration tests:
//  see: https://gitlab.com/gitlab-org/gitlab/-/issues/194207#note_301878738
import { FIXTURES_PATH } from 'spec/test_constants';
import BalsamiqViewer from '~/blob/balsamiq/balsamiq_viewer';

const bmprPath = `${FIXTURES_PATH}/blob/balsamiq/test.bmpr`;

describe('Balsamiq integration spec', () => {
  let container;
  let endpoint;
  let balsamiqViewer;

  preloadFixtures('static/balsamiq_viewer.html');

  beforeEach(() => {
    loadFixtures('static/balsamiq_viewer.html');

    container = document.getElementById('js-balsamiq-viewer');
    balsamiqViewer = new BalsamiqViewer(container);
  });

  describe('successful response', () => {
    beforeEach(done => {
      endpoint = bmprPath;

      balsamiqViewer
        .loadFile(endpoint)
        .then(done)
        .catch(done.fail);
    });

    it('does not show loading icon', () => {
      expect(document.querySelector('.loading')).toBeNull();
    });

    it('renders the balsamiq previews', () => {
      expect(document.querySelectorAll('.previews .preview').length).not.toEqual(0);
    });
  });

  describe('error getting file', () => {
    beforeEach(done => {
      endpoint = 'invalid/path/to/file.bmpr';

      balsamiqViewer
        .loadFile(endpoint)
        .then(done.fail, null)
        .catch(done);
    });

    it('does not show loading icon', () => {
      expect(document.querySelector('.loading')).toBeNull();
    });

    it('does not render the balsamiq previews', () => {
      expect(document.querySelectorAll('.previews .preview').length).toEqual(0);
    });
  });
});