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

logo_spec.js « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e39e75bd3b2285a21e43ade02d24bcd06361889 (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
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import { initPortraitLogoDetection } from '~/logo';

describe('initPortraitLogoDetection', () => {
  let img;

  const loadImage = () => {
    const loadEvent = new Event('load');
    img.dispatchEvent(loadEvent);
  };

  beforeEach(() => {
    setHTMLFixture('<img class="gl-visibility-hidden gl-h-9 js-portrait-logo-detection" />');
    initPortraitLogoDetection();
    img = document.querySelector('img');
  });

  afterEach(() => {
    resetHTMLFixture();
  });

  describe('when logo does not have portrait format', () => {
    beforeEach(() => {
      img.height = 10;
      img.width = 10;
    });

    it('removes gl-visibility-hidden', () => {
      expect(img.classList).toContain('gl-visibility-hidden');
      expect(img.classList).toContain('gl-h-9');

      loadImage();

      expect(img.classList).not.toContain('gl-visibility-hidden');
      expect(img.classList).toContain('gl-h-9');
    });
  });

  describe('when logo has portrait format', () => {
    beforeEach(() => {
      img.height = 11;
      img.width = 10;
    });

    it('removes gl-visibility-hidden', () => {
      expect(img.classList).toContain('gl-visibility-hidden');
      expect(img.classList).toContain('gl-h-9');

      loadImage();

      expect(img.classList).not.toContain('gl-visibility-hidden');
      expect(img.classList).toContain('gl-w-10');
    });
  });
});