diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/frontend/flash_spec.js | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/flash_spec.js')
-rw-r--r-- | spec/frontend/flash_spec.js | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/spec/frontend/flash_spec.js b/spec/frontend/flash_spec.js index 28e8522cc12..96e5202780b 100644 --- a/spec/frontend/flash_spec.js +++ b/spec/frontend/flash_spec.js @@ -1,5 +1,4 @@ import createFlash, { - deprecatedCreateFlash, createFlashEl, createAction, hideFlash, @@ -125,120 +124,6 @@ describe('Flash', () => { }); }); - describe('deprecatedCreateFlash', () => { - const message = 'test'; - const type = 'alert'; - const parent = document; - const actionConfig = null; - const fadeTransition = false; - const addBodyClass = true; - const defaultParams = [message, type, parent, actionConfig, fadeTransition, addBodyClass]; - - describe('no flash-container', () => { - it('does not add to the DOM', () => { - const flashEl = deprecatedCreateFlash(message); - - expect(flashEl).toBeNull(); - - expect(document.querySelector('.flash-alert')).toBeNull(); - }); - }); - - describe('with flash-container', () => { - beforeEach(() => { - setFixtures( - '<div class="content-wrapper js-content-wrapper"><div class="flash-container"></div></div>', - ); - }); - - afterEach(() => { - document.querySelector('.js-content-wrapper').remove(); - }); - - it('adds flash element into container', () => { - deprecatedCreateFlash(...defaultParams); - - expect(document.querySelector('.flash-alert')).not.toBeNull(); - - expect(document.body.className).toContain('flash-shown'); - }); - - it('adds flash into specified parent', () => { - deprecatedCreateFlash( - message, - type, - document.querySelector('.content-wrapper'), - actionConfig, - fadeTransition, - addBodyClass, - ); - - expect(document.querySelector('.content-wrapper .flash-alert')).not.toBeNull(); - expect(document.querySelector('.content-wrapper').innerText.trim()).toEqual(message); - }); - - it('adds container classes when inside content-wrapper', () => { - deprecatedCreateFlash(...defaultParams); - - expect(document.querySelector('.flash-text').className).toBe('flash-text'); - expect(document.querySelector('.content-wrapper').innerText.trim()).toEqual(message); - }); - - it('does not add container when outside of content-wrapper', () => { - document.querySelector('.content-wrapper').className = 'js-content-wrapper'; - deprecatedCreateFlash(...defaultParams); - - expect(document.querySelector('.flash-text').className.trim()).toContain('flash-text'); - }); - - it('removes element after clicking', () => { - deprecatedCreateFlash(...defaultParams); - - document.querySelector('.flash-alert .js-close-icon').click(); - - expect(document.querySelector('.flash-alert')).toBeNull(); - - expect(document.body.className).not.toContain('flash-shown'); - }); - - describe('with actionConfig', () => { - it('adds action link', () => { - const newActionConfig = { title: 'test' }; - deprecatedCreateFlash( - message, - type, - parent, - newActionConfig, - fadeTransition, - addBodyClass, - ); - - expect(document.querySelector('.flash-action')).not.toBeNull(); - }); - - it('calls actionConfig clickHandler on click', () => { - const newActionConfig = { - title: 'test', - clickHandler: jest.fn(), - }; - - deprecatedCreateFlash( - message, - type, - parent, - newActionConfig, - fadeTransition, - addBodyClass, - ); - - document.querySelector('.flash-action').click(); - - expect(newActionConfig.clickHandler).toHaveBeenCalled(); - }); - }); - }); - }); - describe('createFlash', () => { const message = 'test'; const type = 'alert'; |