@@ -4,64 +4,62 @@ import { marshall } from "./marshall";
4
4
jest . mock ( "./convertToAttr" ) ;
5
5
6
6
describe ( "marshall" , ( ) => {
7
- describe ( "mocked convertToAttr" , ( ) => {
8
- const mockOutput = { S : "mockOutput" } ;
9
- ( convertToAttr as jest . Mock ) . mockReturnValue ( { M : mockOutput } ) ;
7
+ const mockOutput = { S : "mockOutput" } ;
8
+ ( convertToAttr as jest . Mock ) . mockReturnValue ( { M : mockOutput } ) ;
10
9
11
- afterEach ( ( ) => {
12
- jest . clearAllMocks ( ) ;
13
- } ) ;
10
+ afterEach ( ( ) => {
11
+ jest . clearAllMocks ( ) ;
12
+ } ) ;
14
13
15
- it ( "with object as an input" , ( ) => {
16
- const input = { a : "A" , b : "B" } ;
17
- expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
18
- expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
19
- expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
20
- } ) ;
14
+ it ( "with object as an input" , ( ) => {
15
+ const input = { a : "A" , b : "B" } ;
16
+ expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
17
+ expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
18
+ expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
19
+ } ) ;
21
20
22
- [ "convertEmptyValues" , "removeUndefinedValues" ] . forEach ( ( option ) => {
23
- describe ( `options.${ option } ` , ( ) => {
24
- [ false , true ] . forEach ( ( value ) => {
25
- it ( `passes ${ value } to convertToAttr` , ( ) => {
26
- const input = { a : "A" , b : "B" } ;
27
- expect ( marshall ( input , { [ option ] : value } ) ) . toEqual ( mockOutput ) ;
28
- expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
29
- expect ( convertToAttr ) . toHaveBeenCalledWith ( input , { [ option ] : value } ) ;
30
- } ) ;
21
+ [ "convertEmptyValues" , "removeUndefinedValues" ] . forEach ( ( option ) => {
22
+ describe ( `options.${ option } ` , ( ) => {
23
+ [ false , true ] . forEach ( ( value ) => {
24
+ it ( `passes ${ value } to convertToAttr` , ( ) => {
25
+ const input = { a : "A" , b : "B" } ;
26
+ expect ( marshall ( input , { [ option ] : value } ) ) . toEqual ( mockOutput ) ;
27
+ expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
28
+ expect ( convertToAttr ) . toHaveBeenCalledWith ( input , { [ option ] : value } ) ;
31
29
} ) ;
32
30
} ) ;
33
31
} ) ;
32
+ } ) ;
34
33
35
- it ( "with type as an input" , ( ) => {
36
- type TestInputType = { a : string ; b : string } ;
37
- const input : TestInputType = { a : "A" , b : "B" } ;
34
+ it ( "with type as an input" , ( ) => {
35
+ type TestInputType = { a : string ; b : string } ;
36
+ const input : TestInputType = { a : "A" , b : "B" } ;
38
37
39
- expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
40
- expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
41
- expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
42
- } ) ;
38
+ expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
39
+ expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
40
+ expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
41
+ } ) ;
43
42
44
- it ( "with Interface as an input" , ( ) => {
45
- interface TestInputInterface {
46
- a : string ;
47
- b : string ;
48
- }
49
- const input : TestInputInterface = { a : "A" , b : "B" } ;
43
+ it ( "with Interface as an input" , ( ) => {
44
+ interface TestInputInterface {
45
+ a : string ;
46
+ b : string ;
47
+ }
48
+ const input : TestInputInterface = { a : "A" , b : "B" } ;
50
49
51
- expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
52
- expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
53
- expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
54
- } ) ;
50
+ expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
51
+ expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
52
+ expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
53
+ } ) ;
55
54
56
- it ( "with class instance as an input" , ( ) => {
57
- class TestInputClass {
58
- constructor ( private readonly a : string , private readonly b : string ) { }
59
- }
60
- const input = new TestInputClass ( "A" , "B" ) ;
55
+ it ( "with class instance as an input" , ( ) => {
56
+ class TestInputClass {
57
+ constructor ( private readonly a : string , private readonly b : string ) { }
58
+ }
59
+ const input = new TestInputClass ( "A" , "B" ) ;
61
60
62
- expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
63
- expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
64
- expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
65
- } ) ;
61
+ expect ( marshall ( input ) ) . toEqual ( mockOutput ) ;
62
+ expect ( convertToAttr ) . toHaveBeenCalledTimes ( 1 ) ;
63
+ expect ( convertToAttr ) . toHaveBeenCalledWith ( input , undefined ) ;
66
64
} ) ;
67
65
} ) ;
0 commit comments