File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 1313
1414import { html , Component , render } from 'htm/preact' ;
1515
16+ const sleep = ms => new Promise ( r => setTimeout ( r , ms ) ) ;
17+
1618describe ( 'htm/preact' , ( ) => {
1719 const scratch = document . createElement ( 'div' ) ;
1820 document . body . appendChild ( scratch ) ;
@@ -57,17 +59,11 @@ describe('htm/preact', () => {
5759 expect ( scratch . innerHTML ) . toBe ( fullHtml . replace ( 'jason' , 'tom' ) ) ;
5860 } ) ;
5961
60- test ( 'state update re-renders' , done => {
62+ test ( 'state update re-renders' , async ( ) => {
6163 document . querySelector ( 'button' ) . click ( ) ;
6264 document . querySelector ( 'button' ) . click ( ) ;
63- setTimeout ( ( ) => {
64- try {
65- expect ( scratch . innerHTML ) . toBe ( fullHtml . replace ( 'jason' , 'tom' ) . replace ( / \b 0 \b / g, '2' ) ) ;
66- }
67- finally {
68- done ( ) ;
69- }
70- } ) ;
65+ await sleep ( 1 ) ;
66+ expect ( scratch . innerHTML ) . toBe ( fullHtml . replace ( 'jason' , 'tom' ) . replace ( / \b 0 \b / g, '2' ) ) ;
7167 } ) ;
7268
7369 test ( 'preserves case' , ( ) => {
You can’t perform that action at this time.
0 commit comments