From 7c3f44451197dd16f68f51eb740259fc1c412237 Mon Sep 17 00:00:00 2001 From: Alexander Fedyashov Date: Fri, 25 Aug 2017 10:20:22 +0300 Subject: [PATCH 1/3] fix(Modal): fix typo in className --- src/modules/Modal/Modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Modal/Modal.js b/src/modules/Modal/Modal.js index 3287e50161..2a4829ead4 100644 --- a/src/modules/Modal/Modal.js +++ b/src/modules/Modal/Modal.js @@ -219,7 +219,7 @@ class Modal extends Component { mountNode.classList.remove('blurring') mountNode.classList.remove('dimmable') mountNode.classList.remove('dimmed') - mountNode.classList.remove('scrollable') + mountNode.classList.remove('scrolling') cancelAnimationFrame(this.animationRequestId) From 77d45dd6c87300f881b57148f8ccf6340599cb3d Mon Sep 17 00:00:00 2001 From: Levi Thomason Date: Sun, 27 Aug 2017 16:29:11 -0700 Subject: [PATCH 2/3] test(Modal): add missing body class coverage --- test/specs/modules/Modal/Modal-test.js | 44 +++++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/test/specs/modules/Modal/Modal-test.js b/test/specs/modules/Modal/Modal-test.js index d151f61b7f..0ea1b0cca1 100644 --- a/test/specs/modules/Modal/Modal-test.js +++ b/test/specs/modules/Modal/Modal-test.js @@ -233,9 +233,14 @@ describe('Modal', () => { }) describe('true', () => { - it('adds classes "dimmable dimmed" to the body', () => { + it('adds/removes body classes "dimmable dimmed" on mount/unmount', () => { + assertBodyClasses('dimmable', 'dimmed', false) + wrapperMount() assertBodyClasses('dimmable', 'dimmed') + + wrapper.unmount() + assertBodyClasses('dimmable', 'dimmed', false) }) it('adds a dimmer to the body', () => { @@ -257,9 +262,14 @@ describe('Modal', () => { }) describe('blurring', () => { - it('adds class "dimmable dimmed blurring" to the body', () => { + it('adds/removes body classes "dimmable dimmed blurring" on mount/unmount', () => { + assertBodyClasses('dimmable', 'dimmed', 'blurring', false) + wrapperMount() assertBodyClasses('dimmable', 'dimmed', 'blurring') + + wrapper.unmount() + assertBodyClasses('dimmable', 'dimmed', 'blurring', false) }) it('adds a dimmer to the body', () => { @@ -269,10 +279,14 @@ describe('Modal', () => { }) describe('inverted', () => { - it('adds class "dimmable dimmed" to the body', () => { - wrapperMount() + it('adds/removes body classes "dimmable dimmed" on mount/unmount', () => { + assertBodyClasses('dimmable', 'dimmed', false) + + wrapperMount() assertBodyClasses('dimmable', 'dimmed') - assertBodyClasses('inverted', false) + + wrapper.unmount() + assertBodyClasses('dimmable', 'dimmed', false) }) it('adds an inverted dimmer to the body', () => { @@ -463,9 +477,8 @@ describe('Modal', () => { }) it('adds the scrolling class to the body when taller than the window', (done) => { - wrapperMount(foo) - window.innerHeight = 10 + wrapperMount(foo) requestAnimationFrame(() => { assertBodyClasses('scrolling') @@ -473,7 +486,7 @@ describe('Modal', () => { }) }) - it('removes the scrolling class from the body when the window grows taller', (done) => { + it('adds/removes the scrolling class to the body when the window grows/shrinks', (done) => { assertBodyClasses('scrolling', false) wrapperMount(foo) @@ -489,5 +502,20 @@ describe('Modal', () => { }) }) }) + + it('removes the scrolling class from the body on unmount', (done) => { + assertBodyClasses('scrolling', false) + + window.innerHeight = 10 + wrapperMount(foo) + + requestAnimationFrame(() => { + assertBodyClasses('scrolling') + wrapper.unmount() + + assertBodyClasses('scrolling', false) + done() + }) + }) }) }) From 7b7d2b987e0449e57afaa412ebc0a337349e9598 Mon Sep 17 00:00:00 2001 From: Alexander Fedyashov Date: Mon, 28 Aug 2017 11:47:13 +0300 Subject: [PATCH 3/3] test(Modal): restore window.innerHeight after tests --- test/specs/modules/Modal/Modal-test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/specs/modules/Modal/Modal-test.js b/test/specs/modules/Modal/Modal-test.js index 4e15ade621..7304b33653 100644 --- a/test/specs/modules/Modal/Modal-test.js +++ b/test/specs/modules/Modal/Modal-test.js @@ -474,10 +474,16 @@ describe('Modal', () => { }) describe('scrolling', () => { + const innerHeight = window.innerHeight + afterEach(() => { document.body.classList.remove('scrolling') }) + after(() => { + window.innerHeight = innerHeight + }) + it('does not add the scrolling class to the body by default', () => { wrapperMount() assertBodyClasses('scrolling', false)