@@ -2,17 +2,15 @@ import _ from '../__fixtures__/any/number';
22import mock from '../__fixtures__/mock' ;
33
44import Complex from '../complex' ;
5- import { Component , invariant } from '../internal' ;
5+ import { Component } from '../internal' ;
66import imag from '../math/imag' ;
77import sut from './imag' ;
88
99jest . mock ( '../complex' ) ;
10- jest . mock ( '../internal/invariant' ) ;
1110jest . mock ( '../internal/principal' ) ;
1211jest . mock ( '../math/imag' ) ;
1312
1413beforeEach ( ( ) => {
15- mock ( invariant ) . mockClear ( ) ;
1614 mock ( imag ) . mockClear ( ) ;
1715} ) ;
1816
@@ -25,9 +23,8 @@ test.each<[Component]>([
2523 const expected = { } as number ;
2624 const z = new Complex ( _ , expected , _ , _ , testHas ) ;
2725
28- const actual = sut ( Complex , z ) ;
26+ const actual = sut ( z ) ;
2927
30- expect ( invariant ) . toHaveBeenCalledWith ( Complex , z ) ;
3128 expect ( imag ) . not . toHaveBeenCalled ( ) ;
3229 expect ( z . _imag ) . toBe ( expected ) ;
3330 expect ( z . _has ) . toBe ( testHas ) ;
@@ -45,26 +42,10 @@ test.each<[Component]>([
4542
4643 mock ( imag ) . mockReturnValueOnce ( expected ) ;
4744
48- const actual = sut ( Complex , z ) ;
45+ const actual = sut ( z ) ;
4946
50- expect ( invariant ) . toHaveBeenCalledWith ( Complex , z ) ;
5147 expect ( imag ) . toHaveBeenCalledWith ( testAbs , testArg ) ;
5248 expect ( z . _imag ) . toBe ( expected ) ;
5349 expect ( z . _has ) . toBe ( testHas | Component . IMAG ) ;
5450 expect ( actual ) . toBe ( expected ) ;
5551} ) ;
56-
57- it ( 'should not modify computed value if invariant is violated' , ( ) => {
58- const z = { } as Complex ;
59- const expected = new TypeError ( ) ;
60-
61- mock ( invariant ) . mockImplementationOnce ( ( ) => {
62- throw expected ;
63- } ) ;
64-
65- expect ( ( ) => sut ( Complex , z ) ) . toThrowError ( expected ) ;
66- expect ( invariant ) . toHaveBeenCalledWith ( Complex , z ) ;
67- expect ( imag ) . not . toHaveBeenCalled ( ) ;
68- expect ( z ) . not . toHaveProperty ( '_imag' ) ;
69- expect ( z ) . not . toHaveProperty ( '_has' ) ;
70- } ) ;
0 commit comments