diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-23 21:11:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-23 21:11:55 +0300 |
commit | 0eb05ee0ea5d4e88a1cae604f7ff92507f16d4b0 (patch) | |
tree | d63a079b11cb16c6a196de48858e299ffbabd12d /spec/frontend/batch_comments/components | |
parent | e01e71a98f4c2d3492d99993d67e7277a2ead698 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/batch_comments/components')
-rw-r--r-- | spec/frontend/batch_comments/components/review_bar_spec.js | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/spec/frontend/batch_comments/components/review_bar_spec.js b/spec/frontend/batch_comments/components/review_bar_spec.js index f98e0a4c64a..f50db6ab210 100644 --- a/spec/frontend/batch_comments/components/review_bar_spec.js +++ b/spec/frontend/batch_comments/components/review_bar_spec.js @@ -6,8 +6,6 @@ import createStore from '../create_batch_comments_store'; describe('Batch comments review bar component', () => { let store; let wrapper; - let addEventListenerSpy; - let removeEventListenerSpy; const createComponent = (propsData = {}) => { store = createStore(); @@ -20,58 +18,25 @@ describe('Batch comments review bar component', () => { beforeEach(() => { document.body.className = ''; - - addEventListenerSpy = jest.spyOn(window, 'addEventListener'); - removeEventListenerSpy = jest.spyOn(window, 'removeEventListener'); }); afterEach(() => { - addEventListenerSpy.mockRestore(); - removeEventListenerSpy.mockRestore(); wrapper.destroy(); }); - describe('when mounted', () => { - it('it adds review-bar-visible class to body', async () => { - expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false); - - createComponent(); - - expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(true); - }); + it('it adds review-bar-visible class to body when review bar is mounted', async () => { + expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false); - it('it adds a blocking handler to the `beforeunload` window event', () => { - expect(addEventListenerSpy).not.toBeCalled(); + createComponent(); - createComponent(); - - expect(addEventListenerSpy).toHaveBeenCalledTimes(1); - expect(addEventListenerSpy).toBeCalledWith('beforeunload', expect.any(Function), { - capture: true, - }); - }); + expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(true); }); - describe('before destroyed', () => { - it('it removes review-bar-visible class to body', async () => { - createComponent(); - - wrapper.destroy(); + it('it removes review-bar-visible class to body when review bar is destroyed', async () => { + createComponent(); - expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false); - }); - - it('it removes the blocking handler from the `beforeunload` window event', () => { - createComponent(); - - expect(removeEventListenerSpy).not.toBeCalled(); - - wrapper.destroy(); + wrapper.destroy(); - expect(removeEventListenerSpy).toHaveBeenCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledWith('beforeunload', expect.any(Function), { - capture: true, - }); - }); + expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false); }); }); |