diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-14 12:09:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-14 12:09:56 +0300 |
commit | 3c0faf1c6b40536c7b7687225ff4e03e884192d5 (patch) | |
tree | c81ab92ae5a27c6a046e593810f30b231eab7788 /spec/frontend | |
parent | 671c8718a9762eb4e698cb7547cffa255e0ae322 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/logo_spec.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/frontend/logo_spec.js b/spec/frontend/logo_spec.js new file mode 100644 index 00000000000..8e39e75bd3b --- /dev/null +++ b/spec/frontend/logo_spec.js @@ -0,0 +1,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'); + }); + }); +}); |