Skip to content

Commit 3d6d644

Browse files
committed
Mock window.matchMedia
1 parent dcfafd2 commit 3d6d644

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ describe('typing-effect', function () {
7979
})
8080

8181
describe('a11y considerations', function () {
82+
let realMatchMedia
83+
before(() => {
84+
realMatchMedia = window.matchMedia
85+
window.matchMedia = mediaString => {
86+
if (mediaString === '(prefers-reduced-motion)') {
87+
return {matches: true}
88+
}
89+
return realMatchMedia(mediaString)
90+
}
91+
})
92+
93+
after(() => {
94+
window.matchMedia = realMatchMedia
95+
})
96+
8297
it('sets delay to 0 when media query matches (prefers-reduced-motion)', function () {
8398
const typingEffectElement = document.createElement('typing-effect')
8499
document.body.append(typingEffectElement)

0 commit comments

Comments
 (0)