@@ -48,16 +48,16 @@ describe('Record', () => {
48
48
it ( 'setting an unknown key is a no-op' , ( ) => {
49
49
const MyType = Record ( { a : 1 , b : 2 , c : 3 } ) ;
50
50
51
- const t1 = new MyType ( { a : 10 , b : 20 } ) ;
51
+ const t1 = MyType ( { a : 10 , b : 20 } ) ;
52
52
const t2 = t1 . set ( 'd' as any , 4 ) ;
53
53
54
54
expect ( t2 ) . toBe ( t1 ) ;
55
55
} ) ;
56
56
57
57
it ( 'falls back to default values when deleted or cleared' , ( ) => {
58
58
const MyType = Record ( { a : 1 , b : 2 , c : 3 } ) ;
59
- const t1 = new MyType ( { a : 10 , b : 20 } ) ;
60
- const t2 = new MyType ( { b : 20 } ) ;
59
+ const t1 = MyType ( { a : 10 , b : 20 } ) ;
60
+ const t2 = MyType ( { b : 20 } ) ;
61
61
const t3 = t1 . delete ( 'a' ) ;
62
62
const t4 = t3 . clear ( ) ;
63
63
@@ -68,13 +68,13 @@ describe('Record', () => {
68
68
69
69
expect ( t2 . equals ( t3 ) ) . toBe ( true ) ;
70
70
expect ( t2 . equals ( t4 ) ) . toBe ( false ) ;
71
- expect ( t4 . equals ( new MyType ( ) ) ) . toBe ( true ) ;
71
+ expect ( t4 . equals ( MyType ( ) ) ) . toBe ( true ) ;
72
72
} ) ;
73
73
74
74
it ( 'allows deletion of values deep within a tree' , ( ) => {
75
75
const AType = Record ( { a : 1 } ) ;
76
- const BType = Record ( { b : new AType ( { a : 2 } ) } ) ;
77
- const t1 = new BType ( ) ;
76
+ const BType = Record ( { b : AType ( { a : 2 } ) } ) ;
77
+ const t1 = BType ( ) ;
78
78
const t2 = t1 . deleteIn ( [ 'b' , 'a' ] ) ;
79
79
80
80
expect ( t1 . get ( 'b' ) . get ( 'a' ) ) . toBe ( 2 ) ;
@@ -90,7 +90,7 @@ describe('Record', () => {
90
90
91
91
it ( 'if compared against undefined or null should return false' , ( ) => {
92
92
const MyType = Record ( { a : 1 , b : 2 } ) ;
93
- const t1 = new MyType ( ) ;
93
+ const t1 = MyType ( ) ;
94
94
expect ( t1 . equals ( undefined ) ) . toBeFalsy ( ) ;
95
95
expect ( t1 . equals ( null ) ) . toBeFalsy ( ) ;
96
96
} ) ;
@@ -115,7 +115,7 @@ describe('Record', () => {
115
115
it ( 'converts sequences to records' , ( ) => {
116
116
const MyType = Record ( { a : 1 , b : 2 , c : 3 } ) ;
117
117
const seq = Seq ( { a : 10 , b : 20 } ) ;
118
- const t = new MyType ( seq ) ;
118
+ const t = MyType ( seq ) ;
119
119
expect ( t . toObject ( ) ) . toEqual ( { a : 10 , b : 20 , c : 3 } ) ;
120
120
} ) ;
121
121
@@ -129,7 +129,7 @@ describe('Record', () => {
129
129
it ( 'skips unknown keys' , ( ) => {
130
130
const MyType = Record ( { a : 1 , b : 2 } ) ;
131
131
const seq = Seq ( { b : 20 , c : 30 } ) ;
132
- const t = new MyType ( seq ) ;
132
+ const t = MyType ( seq ) ;
133
133
134
134
expect ( t . get ( 'a' ) ) . toEqual ( 1 ) ;
135
135
expect ( t . get ( 'b' ) ) . toEqual ( 20 ) ;
@@ -138,18 +138,18 @@ describe('Record', () => {
138
138
139
139
it ( 'returns itself when setting identical values' , ( ) => {
140
140
const MyType = Record ( { a : 1 , b : 2 } ) ;
141
- const t1 = new MyType ( ) ;
142
- const t2 = new MyType ( { a : 1 } ) ;
141
+ const t1 = MyType ( ) ;
142
+ const t2 = MyType ( { a : 1 } ) ;
143
143
const t3 = t1 . set ( 'a' , 1 ) ;
144
144
const t4 = t2 . set ( 'a' , 1 ) ;
145
145
expect ( t3 ) . toBe ( t1 ) ;
146
146
expect ( t4 ) . toBe ( t2 ) ;
147
147
} ) ;
148
148
149
- it ( 'returns new record when setting new values' , ( ) => {
149
+ it ( 'returns record when setting values' , ( ) => {
150
150
const MyType = Record ( { a : 1 , b : 2 } ) ;
151
- const t1 = new MyType ( ) ;
152
- const t2 = new MyType ( { a : 1 } ) ;
151
+ const t1 = MyType ( ) ;
152
+ const t2 = MyType ( { a : 1 } ) ;
153
153
const t3 = t1 . set ( 'a' , 3 ) ;
154
154
const t4 = t2 . set ( 'a' , 3 ) ;
155
155
expect ( t3 ) . not . toBe ( t1 ) ;
@@ -158,7 +158,7 @@ describe('Record', () => {
158
158
159
159
it ( 'allows for readonly property access' , ( ) => {
160
160
const MyType = Record ( { a : 1 , b : 'foo' } ) ;
161
- const t1 = new MyType ( ) ;
161
+ const t1 = MyType ( ) ;
162
162
const a : number = t1 . a ;
163
163
const b : string = t1 . b ;
164
164
expect ( a ) . toEqual ( 1 ) ;
@@ -179,6 +179,7 @@ describe('Record', () => {
179
179
}
180
180
}
181
181
182
+ // Note: `new` is only used because of `class`
182
183
const t1 = new ABClass ( { a : 1 } ) ;
183
184
const t2 = t1 . setA ( 3 ) ;
184
185
const t3 = t2 . setB ( 10 ) ;
0 commit comments