@@ -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 )
@@ -89,6 +104,32 @@ describe('typing-effect', function () {
89104 assert . equal ( typingEffectElement . lineDelay , lineDelay )
90105 } )
91106 } )
107+
108+ describe ( 'a11y considerations' , function ( ) {
109+ let realMatchMedia
110+ before ( ( ) => {
111+ realMatchMedia = window . matchMedia
112+ window . matchMedia = mediaString => {
113+ if ( mediaString === '(prefers-reduced-motion)' ) {
114+ return { matches : true }
115+ }
116+ return realMatchMedia ( mediaString )
117+ }
118+ } )
119+
120+ after ( ( ) => {
121+ window . matchMedia = realMatchMedia
122+ } )
123+
124+ it ( 'sets delay to 0 when media query matches (prefers-reduced-motion)' , function ( ) {
125+ const typingEffectElement = document . createElement ( 'typing-effect' )
126+ document . body . append ( typingEffectElement )
127+
128+ assert . equal ( window . matchMedia ( '(prefers-reduced-motion)' ) . matches , true )
129+ assert . equal ( typingEffectElement . characterDelay , 0 )
130+ assert . equal ( typingEffectElement . lineDelay , 0 )
131+ } )
132+ } )
92133} )
93134
94135function once ( element , eventName ) {
0 commit comments