1- import { selectIdValue } from '../utils'
21import { AClockworkOrange } from './fixtures/book'
32
43describe ( 'Entity utils' , ( ) => {
@@ -12,26 +11,29 @@ describe('Entity utils', () => {
1211
1312 afterEach ( ( ) => {
1413 process . env = OLD_ENV
14+ jest . resetAllMocks ( )
1515 } )
1616
1717 it ( 'should not warn when key does exist' , ( ) => {
18- const spy = spyOn ( console , 'warn' )
19-
20- selectIdValue ( AClockworkOrange , ( book ) => book . id )
18+ const { selectIdValue } = require ( '../utils' )
19+ const spy = jest . spyOn ( console , 'warn' )
2120
21+ selectIdValue ( AClockworkOrange , ( book : any ) => book . id )
2222 expect ( spy ) . not . toHaveBeenCalled ( )
2323 } )
2424
2525 it ( 'should warn when key does not exist in dev mode' , ( ) => {
26- const spy = spyOn ( console , 'warn' )
26+ const { selectIdValue } = require ( '../utils' )
27+ const spy = jest . spyOn ( console , 'warn' )
2728
2829 selectIdValue ( AClockworkOrange , ( book : any ) => book . foo )
2930
3031 expect ( spy ) . toHaveBeenCalled ( )
3132 } )
3233
3334 it ( 'should warn when key is undefined in dev mode' , ( ) => {
34- const spy = spyOn ( console , 'warn' )
35+ const { selectIdValue } = require ( '../utils' )
36+ const spy = jest . spyOn ( console , 'warn' )
3537
3638 const undefinedAClockworkOrange = { ...AClockworkOrange , id : undefined }
3739 selectIdValue ( undefinedAClockworkOrange , ( book : any ) => book . id )
@@ -41,7 +43,8 @@ describe('Entity utils', () => {
4143
4244 it ( 'should not warn when key does not exist in prod mode' , ( ) => {
4345 process . env . NODE_ENV = 'production'
44- const spy = spyOn ( console , 'warn' )
46+ const { selectIdValue } = require ( '../utils' )
47+ const spy = jest . spyOn ( console , 'warn' )
4548
4649 selectIdValue ( AClockworkOrange , ( book : any ) => book . foo )
4750
@@ -50,7 +53,8 @@ describe('Entity utils', () => {
5053
5154 it ( 'should not warn when key is undefined in prod mode' , ( ) => {
5255 process . env . NODE_ENV = 'production'
53- const spy = spyOn ( console , 'warn' )
56+ const { selectIdValue } = require ( '../utils' )
57+ const spy = jest . spyOn ( console , 'warn' )
5458
5559 const undefinedAClockworkOrange = { ...AClockworkOrange , id : undefined }
5660 selectIdValue ( undefinedAClockworkOrange , ( book : any ) => book . id )
0 commit comments