Skip to content

Commit b23baec

Browse files
layershifterAlexander Fedyashov
authored and
Alexander Fedyashov
committed
fix(Modal): fix typo in className (#2004)
* fix(Modal): fix typo in className * test(Modal): add missing body class coverage * test(Modal): restore window.innerHeight after tests
1 parent caa9a0a commit b23baec

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

src/modules/Modal/Modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class Modal extends Component {
227227
mountNode.classList.remove('blurring')
228228
mountNode.classList.remove('dimmable')
229229
mountNode.classList.remove('dimmed')
230-
mountNode.classList.remove('scrollable')
230+
mountNode.classList.remove('scrolling')
231231

232232
cancelAnimationFrame(this.animationRequestId)
233233

test/specs/modules/Modal/Modal-test.js

+42-8
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,14 @@ describe('Modal', () => {
240240
})
241241

242242
describe('true', () => {
243-
it('adds classes "dimmable dimmed" to the body', () => {
243+
it('adds/removes body classes "dimmable dimmed" on mount/unmount', () => {
244+
assertBodyClasses('dimmable', 'dimmed', false)
245+
244246
wrapperMount(<Modal open dimmer />)
245247
assertBodyClasses('dimmable', 'dimmed')
248+
249+
wrapper.unmount()
250+
assertBodyClasses('dimmable', 'dimmed', false)
246251
})
247252

248253
it('adds a dimmer to the body', () => {
@@ -264,9 +269,14 @@ describe('Modal', () => {
264269
})
265270

266271
describe('blurring', () => {
267-
it('adds class "dimmable dimmed blurring" to the body', () => {
272+
it('adds/removes body classes "dimmable dimmed blurring" on mount/unmount', () => {
273+
assertBodyClasses('dimmable', 'dimmed', 'blurring', false)
274+
268275
wrapperMount(<Modal open dimmer='blurring' />)
269276
assertBodyClasses('dimmable', 'dimmed', 'blurring')
277+
278+
wrapper.unmount()
279+
assertBodyClasses('dimmable', 'dimmed', 'blurring', false)
270280
})
271281

272282
it('adds a dimmer to the body', () => {
@@ -276,10 +286,14 @@ describe('Modal', () => {
276286
})
277287

278288
describe('inverted', () => {
279-
it('adds class "dimmable dimmed" to the body', () => {
280-
wrapperMount(<Modal open dimmer='inverted' />)
289+
it('adds/removes body classes "dimmable dimmed" on mount/unmount', () => {
290+
assertBodyClasses('dimmable', 'dimmed', false)
291+
292+
wrapperMount(<Modal open dimmer />)
281293
assertBodyClasses('dimmable', 'dimmed')
282-
assertBodyClasses('inverted', false)
294+
295+
wrapper.unmount()
296+
assertBodyClasses('dimmable', 'dimmed', false)
283297
})
284298

285299
it('adds an inverted dimmer to the body', () => {
@@ -460,27 +474,32 @@ describe('Modal', () => {
460474
})
461475

462476
describe('scrolling', () => {
477+
const innerHeight = window.innerHeight
478+
463479
afterEach(() => {
464480
document.body.classList.remove('scrolling')
465481
})
466482

483+
after(() => {
484+
window.innerHeight = innerHeight
485+
})
486+
467487
it('does not add the scrolling class to the body by default', () => {
468488
wrapperMount(<Modal open />)
469489
assertBodyClasses('scrolling', false)
470490
})
471491

472492
it('adds the scrolling class to the body when taller than the window', (done) => {
473-
wrapperMount(<Modal open>foo</Modal>)
474-
475493
window.innerHeight = 10
494+
wrapperMount(<Modal open>foo</Modal>)
476495

477496
requestAnimationFrame(() => {
478497
assertBodyClasses('scrolling')
479498
done()
480499
})
481500
})
482501

483-
it('removes the scrolling class from the body when the window grows taller', (done) => {
502+
it('adds/removes the scrolling class to the body when the window grows/shrinks', (done) => {
484503
assertBodyClasses('scrolling', false)
485504

486505
wrapperMount(<Modal open>foo</Modal>)
@@ -496,5 +515,20 @@ describe('Modal', () => {
496515
})
497516
})
498517
})
518+
519+
it('removes the scrolling class from the body on unmount', (done) => {
520+
assertBodyClasses('scrolling', false)
521+
522+
window.innerHeight = 10
523+
wrapperMount(<Modal open>foo</Modal>)
524+
525+
requestAnimationFrame(() => {
526+
assertBodyClasses('scrolling')
527+
wrapper.unmount()
528+
529+
assertBodyClasses('scrolling', false)
530+
done()
531+
})
532+
})
499533
})
500534
})

0 commit comments

Comments
 (0)