File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,19 @@ suite('relative-time', function () {
58
58
assert . equal ( counter , 1 )
59
59
} )
60
60
61
+ test ( 'updates the time automatically when it is a few seconds ago' , async function ( ) {
62
+ this . timeout ( 3000 )
63
+ const el = document . createElement ( 'relative-time' )
64
+ el . setAttribute ( 'datetime' , new Date ( Date . now ( ) + 25000 ) . toISOString ( ) )
65
+ const display = el . shadowRoot ?. textContent || el . textContent
66
+ assert . match ( display , / i n \d + s e c o n d s / )
67
+ await new Promise ( resolve => setTimeout ( resolve , 2000 ) )
68
+ const nextDisplay = el . shadowRoot . textContent || el . textContent
69
+ assert . match ( nextDisplay , / i n \d + s e c o n d s / )
70
+ console . log ( nextDisplay , display )
71
+ assert . notEqual ( nextDisplay , display )
72
+ } )
73
+
61
74
test ( "doesn't error when no date is provided" , function ( ) {
62
75
const element = document . createElement ( 'relative-time' )
63
76
assert . doesNotThrow ( ( ) => element . attributeChangedCallback ( 'datetime' , null , null ) )
You can’t perform that action at this time.
0 commit comments