@@ -68,6 +68,21 @@ describe('typing-effect', function () {
6868 } )
6969
7070 describe ( 'delay attributes' , function ( ) {
71+ let realMatchMedia
72+ before ( ( ) => {
73+ realMatchMedia = window . matchMedia
74+ window . matchMedia = mediaString => {
75+ if ( mediaString === '(prefers-reduced-motion)' ) {
76+ return { matches : false }
77+ }
78+ return realMatchMedia ( mediaString )
79+ }
80+ } )
81+
82+ after ( ( ) => {
83+ window . matchMedia = realMatchMedia
84+ } )
85+
7186 it ( 'uses defaults when no delays specified' , function ( ) {
7287 const typingEffectElement = document . createElement ( 'typing-effect' )
7388 document . body . append ( typingEffectElement )
@@ -76,6 +91,32 @@ describe('typing-effect', function () {
7691 assert . equal ( typingEffectElement . lineDelay , 40 )
7792 } )
7893 } )
94+
95+ describe ( 'a11y considerations' , function ( ) {
96+ let realMatchMedia
97+ before ( ( ) => {
98+ realMatchMedia = window . matchMedia
99+ window . matchMedia = mediaString => {
100+ if ( mediaString === '(prefers-reduced-motion)' ) {
101+ return { matches : true }
102+ }
103+ return realMatchMedia ( mediaString )
104+ }
105+ } )
106+
107+ after ( ( ) => {
108+ window . matchMedia = realMatchMedia
109+ } )
110+
111+ it ( 'sets delay to 0 when media query matches (prefers-reduced-motion)' , function ( ) {
112+ const typingEffectElement = document . createElement ( 'typing-effect' )
113+ document . body . append ( typingEffectElement )
114+
115+ assert . equal ( window . matchMedia ( '(prefers-reduced-motion)' ) . matches , true )
116+ assert . equal ( typingEffectElement . characterDelay , 0 )
117+ assert . equal ( typingEffectElement . lineDelay , 0 )
118+ } )
119+ } )
79120} )
80121
81122function once ( element , eventName ) {
0 commit comments