@@ -27,4 +27,43 @@ describe('typing-effect', function () {
27
27
assert . equal ( ce . textContent , '' )
28
28
} )
29
29
} )
30
+
31
+ describe ( 'content typing' , function ( ) {
32
+ it ( 'types a single line' , function ( done ) {
33
+ const line = 'Welcome to GitHub!'
34
+ const container = document . createElement ( 'div' )
35
+ container . innerHTML = `
36
+ <typing-effect data-lines='["${ line } "]'>
37
+ <span data-target="typing-effect.content"></span>
38
+ <span data-target="typing-effect.cursor">|</span>
39
+ </typing-effect>
40
+ `
41
+ const contentSpan = container . querySelector ( 'span[data-target="typing-effect.content"]' )
42
+ document . body . append ( container )
43
+
44
+ setTimeout ( ( ) => {
45
+ assert . equal ( contentSpan . textContent , line )
46
+ done ( )
47
+ } , 1500 )
48
+ } )
49
+
50
+ it ( 'types multiple lines' , function ( done ) {
51
+ const lineOne = 'Welcome!'
52
+ const lineTwo = 'Let‘s begin'
53
+ const container = document . createElement ( 'div' )
54
+ container . innerHTML = `
55
+ <typing-effect data-lines='["${ lineOne } ", "${ lineTwo } "]'>
56
+ <span data-target="typing-effect.content"></span>
57
+ <span data-target="typing-effect.cursor">|</span>
58
+ </typing-effect>
59
+ `
60
+ const contentSpan = container . querySelector ( 'span[data-target="typing-effect.content"]' )
61
+ document . body . append ( container )
62
+
63
+ setTimeout ( ( ) => {
64
+ assert . equal ( contentSpan . innerHTML , `${ lineOne } <br>${ lineTwo } ` )
65
+ done ( )
66
+ } , 1500 )
67
+ } )
68
+ } )
30
69
} )
0 commit comments