@@ -15,6 +15,10 @@ import {
1515 throttle
1616} from "../src"
1717
18+ beforeEach ( ( ) => {
19+ document . body . innerHTML = ""
20+ } )
21+
1822describe ( "withFx" , ( ) => {
1923 it ( "should be a function" , ( ) => expect ( withFx ) . toBeInstanceOf ( Function ) )
2024 it ( "should call view without actions" , done =>
@@ -35,7 +39,8 @@ describe("withFx", () => {
3539 exit : ( ) => {
3640 done ( )
3741 }
38- }
42+ } ,
43+ Function . prototype
3944 )
4045
4146 expect ( main . get ( ) ) . toEqual ( {
@@ -71,7 +76,8 @@ describe("withFx", () => {
7176 { } ,
7277 {
7378 foo : ( ) => action ( "unknown" )
74- }
79+ } ,
80+ Function . prototype
7581 ) . foo ( )
7682 ) . toThrow ( "couldn't find action: unknown" ) )
7783 it ( "should throw for unknown slice actions" , ( ) =>
@@ -80,7 +86,8 @@ describe("withFx", () => {
8086 { } ,
8187 {
8288 foo : ( ) => action ( "uh.oh" )
83- }
89+ } ,
90+ Function . prototype
8491 ) . foo ( )
8592 ) . toThrow ( "couldn't find action: uh.oh" ) )
8693 it ( "should fire a chained action" , done =>
@@ -92,7 +99,8 @@ describe("withFx", () => {
9299 expect ( data ) . toEqual ( { some : "data" } )
93100 done ( )
94101 }
95- }
102+ } ,
103+ Function . prototype
96104 ) . foo ( ) )
97105 it ( "should fire a slice action" , done =>
98106 withFx ( app ) (
@@ -105,7 +113,8 @@ describe("withFx", () => {
105113 done ( )
106114 }
107115 }
108- }
116+ } ,
117+ Function . prototype
109118 ) . foo ( ) )
110119 it ( "should update state" , done =>
111120 withFx ( app ) (
@@ -132,10 +141,10 @@ describe("withFx", () => {
132141 expect ( data ) . toEqual ( { moar : "stuff" } )
133142 done ( )
134143 }
135- }
144+ } ,
145+ Function . prototype
136146 ) . foo ( ) )
137147 it ( "should attach to listeners in view" , done => {
138- document . body . innerHTML = ""
139148 withFx ( app ) (
140149 {
141150 message : "hello"
@@ -182,7 +191,8 @@ describe("withFx", () => {
182191 done ( )
183192 }
184193 }
185- }
194+ } ,
195+ Function . prototype
186196 )
187197 main . foo ( )
188198 expect ( requestAnimationFrame ) . toBeCalledWith ( expect . any ( Function ) )
@@ -216,9 +226,7 @@ describe("withFx", () => {
216226 describe ( "time" , ( ) => {
217227 it ( "should get the current time" , done => {
218228 const timestamp = 9001
219- global . performance = {
220- now : ( ) => timestamp
221- }
229+ global . performance . now = ( ) => timestamp
222230 withFx ( app ) (
223231 { } ,
224232 {
@@ -229,9 +237,10 @@ describe("withFx", () => {
229237 done ( )
230238 }
231239 }
232- }
240+ } ,
241+ Function . prototype
233242 ) . foo ( )
234- delete global . performance
243+ delete global . performance . now
235244 } )
236245 } )
237246 /* eslint-disable no-console */
@@ -247,7 +256,8 @@ describe("withFx", () => {
247256 { } ,
248257 {
249258 foo : ( ) => log ( ...testArgs )
250- }
259+ } ,
260+ Function . prototype
251261 ) . foo ( )
252262 console . log = defaultLog
253263 } )
@@ -276,7 +286,8 @@ describe("withFx", () => {
276286 done ( )
277287 }
278288 }
279- }
289+ } ,
290+ Function . prototype
280291 ) . foo ( )
281292 delete global . fetch
282293 } )
@@ -300,7 +311,8 @@ describe("withFx", () => {
300311 done ( )
301312 }
302313 }
303- }
314+ } ,
315+ Function . prototype
304316 ) . foo ( )
305317 delete global . fetch
306318 } )
@@ -334,7 +346,8 @@ describe("withFx", () => {
334346 done ( )
335347 }
336348 }
337- }
349+ } ,
350+ Function . prototype
338351 ) . foo ( )
339352 delete global . fetch
340353 } )
@@ -365,7 +378,8 @@ describe("withFx", () => {
365378 done . fail ( new Error ( "Should not be called" ) )
366379 }
367380 }
368- }
381+ } ,
382+ Function . prototype
369383 ) . foo ( )
370384 delete global . fetch
371385 } )
@@ -388,7 +402,8 @@ describe("withFx", () => {
388402 done ( )
389403 }
390404 }
391- }
405+ } ,
406+ Function . prototype
392407 ) . foo ( )
393408 delete global . fetch
394409 } )
@@ -413,14 +428,14 @@ describe("withFx", () => {
413428 done ( )
414429 }
415430 }
416- }
431+ } ,
432+ Function . prototype
417433 ) . foo ( )
418434 delete global . fetch
419435 } )
420436 } )
421437 describe ( "event" , ( ) => {
422438 it ( "should attach to listeners in view" , done => {
423- document . body . innerHTML = ""
424439 withFx ( app ) (
425440 {
426441 message : "hello"
@@ -464,7 +479,8 @@ describe("withFx", () => {
464479 expect ( data ) . toEqual ( keyEvent )
465480 done ( )
466481 }
467- }
482+ } ,
483+ Function . prototype
468484 ) . init ( )
469485 document . onkeydown ( keyEvent )
470486 } )
@@ -480,7 +496,8 @@ describe("withFx", () => {
480496 expect ( data ) . toEqual ( keyEvent )
481497 done ( )
482498 }
483- }
499+ } ,
500+ Function . prototype
484501 ) . init ( )
485502 document . onkeyup ( keyEvent )
486503 } )
@@ -499,7 +516,8 @@ describe("withFx", () => {
499516 expect ( data ) . toBeCloseTo ( randomValue )
500517 done ( )
501518 }
502- }
519+ } ,
520+ Function . prototype
503521 ) . foo ( )
504522
505523 Math . random = defaultRandom
@@ -517,7 +535,8 @@ describe("withFx", () => {
517535 expect ( data ) . toBeCloseTo ( 3.5 )
518536 done ( )
519537 }
520- }
538+ } ,
539+ Function . prototype
521540 ) . foo ( )
522541
523542 Math . random = defaultRandom
@@ -646,7 +665,6 @@ describe("withFx", () => {
646665 } )
647666 } )
648667 it ( "should allow combining action and event fx in view" , done => {
649- document . body . innerHTML = ""
650668 withFx ( app ) (
651669 {
652670 message : "hello"
@@ -699,7 +717,8 @@ describe("withFx", () => {
699717 foo : ( ) => [ "set" , { action : "set" } ] ,
700718 set : state => state ,
701719 get : ( ) => state => state
702- }
720+ } ,
721+ Function . prototype
703722 )
704723
705724 expect ( main . get ( ) ) . toEqual ( {
@@ -734,7 +753,8 @@ describe("withFx", () => {
734753 "expected bar not to be called with overridden action effect!"
735754 )
736755 }
737- }
756+ } ,
757+ Function . prototype
738758 ) . foo ( )
739759
740760 expect ( actionLog ) . toEqual ( [
0 commit comments