@@ -49,53 +49,53 @@ describe("Map with one object", () => {
49
49
assert ( arrayStringMap . has ( sampleArray1 ) ) ;
50
50
} )
51
51
it ( "Map entries returns array with one object" , ( ) => {
52
- assert ( [ ...arrayStringMap . entries ( ) ] . length === 1 ) ;
53
- assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 0 ] === sampleArray1 ) ;
54
- assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 1 ] === sampleValue1 ) ;
52
+ assert ( [ ...arrayStringMap . entries ( ) ] . length === 1 , "Array length is 1" ) ;
53
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 0 ] === sampleArray1 , "Array is sampleArray1" ) ;
54
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 1 ] === sampleValue1 , "Value is sampleValue1" ) ;
55
55
} )
56
56
it ( "Map keys returns array with one object" , ( ) => {
57
- assert ( [ ...arrayStringMap . keys ( ) ] . length === 1 ) ;
58
- assert ( [ ...arrayStringMap . keys ( ) ] [ 0 ] === sampleArray1 ) ;
57
+ assert ( [ ...arrayStringMap . keys ( ) ] . length === 1 , "Array length is 1" ) ;
58
+ assert ( [ ...arrayStringMap . keys ( ) ] [ 0 ] === sampleArray1 , "Array is sampleArray1" ) ;
59
59
} )
60
60
it ( "Map values returns array with one value" , ( ) => {
61
- assert ( [ ...arrayStringMap . values ( ) ] . length === 1 ) ;
62
- assert ( [ ...arrayStringMap . values ( ) ] [ 0 ] === sampleValue1 ) ;
61
+ assert ( [ ...arrayStringMap . values ( ) ] . length === 1 , "Array length is 1" ) ;
62
+ assert ( [ ...arrayStringMap . values ( ) ] [ 0 ] === sampleValue1 , "Value is sampleValue1" ) ;
63
63
} )
64
64
it ( "Map uses proper separator underneath" , ( ) => {
65
65
// @ts -ignore - this is a test, and we need to make sure the underlying map
66
66
// works as expected
67
- assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 0 ] . includes ( "\u200b" ) ) ;
67
+ assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 0 ] . includes ( "\u200b" ) , "Separator is present" ) ;
68
68
// @ts -ignore - this is a test, and we need to make sure the underlying encoding map
69
69
// works as expected
70
- assert ( [ ...arrayStringMap . _converterInfo . values ( ) ] [ 0 ] === sampleArray1 ) ;
70
+ assert ( [ ...arrayStringMap . _converterInfo . values ( ) ] [ 0 ] === sampleArray1 , "Converter info is sampleArray1" ) ;
71
71
} )
72
72
it ( "Clearing map removes object" , ( ) => {
73
73
const copiedMap = copyArrayStringMap ( arrayStringMap ) ;
74
74
copiedMap . clear ( ) ;
75
- assert ( copiedMap . size === 0 ) ;
76
- assert ( copiedMap . get ( sampleArray1 ) === undefined ) ;
77
- assert ( ! copiedMap . has ( sampleArray1 ) ) ;
78
- assert ( [ ...copiedMap . entries ( ) ] . length === 0 ) ;
75
+ assert ( copiedMap . size === 0 , "Map size is 0" ) ;
76
+ assert ( copiedMap . get ( sampleArray1 ) === undefined , "Map get returns undefined" ) ;
77
+ assert ( ! copiedMap . has ( sampleArray1 ) , "Map has returns false" ) ;
78
+ assert ( [ ...copiedMap . entries ( ) ] . length === 0 , "Map entries returns empty array" ) ;
79
79
// @ts -ignore - this is a test, and we need to make sure the underlying map
80
80
// works as expected
81
- assert ( copiedMap . _map . size === 0 ) ;
81
+ assert ( copiedMap . _map . size === 0 , "Data map size is 0" ) ;
82
82
// @ts -ignore - this is a test, and we need to make sure the underlying encoding map
83
83
// works as expected
84
- assert ( copiedMap . _converterInfo . size === 0 ) ;
84
+ assert ( copiedMap . _converterInfo . size === 0 , "Converter map size is 0" ) ;
85
85
} )
86
86
it ( "Deleting entry from map removes object" , ( ) => {
87
87
const copiedMap = copyArrayStringMap ( arrayStringMap ) ;
88
88
copiedMap . delete ( sampleArray1 ) ;
89
- assert ( copiedMap . size === 0 ) ;
90
- assert ( copiedMap . get ( sampleArray1 ) === undefined ) ;
91
- assert ( ! copiedMap . has ( sampleArray1 ) ) ;
92
- assert ( [ ...copiedMap . entries ( ) ] . length === 0 ) ;
89
+ assert ( copiedMap . size === 0 , "Map size is 0" ) ;
90
+ assert ( copiedMap . get ( sampleArray1 ) === undefined , "Map get returns undefined" ) ;
91
+ assert ( ! copiedMap . has ( sampleArray1 ) , "Map has returns false" ) ;
92
+ assert ( [ ...copiedMap . entries ( ) ] . length === 0 , "Map entries returns empty array" ) ;
93
93
// @ts -ignore - this is a test, and we need to make sure the underlying map
94
94
// works as expected
95
- assert ( copiedMap . _map . size === 0 ) ;
95
+ assert ( copiedMap . _map . size === 0 , "Data map size is 0" ) ;
96
96
// @ts -ignore - this is a test, and we need to make sure the underlying encoding map
97
97
// works as expected
98
- assert ( copiedMap . _converterInfo . size === 0 ) ;
98
+ assert ( copiedMap . _converterInfo . size === 0 , "Converter map size is 0" ) ;
99
99
} )
100
100
} )
101
101
@@ -105,7 +105,7 @@ describe("Map with one object and different separator", () => {
105
105
it ( "Map uses proper encoding underneath" , ( ) => {
106
106
// @ts -ignore - this is a test, and we need to make sure the underlying item
107
107
// works as expected
108
- assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 0 ] . includes ( ":" ) ) ;
108
+ assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 0 ] . includes ( ":" ) , "Separator is present" ) ;
109
109
} )
110
110
} )
111
111
@@ -126,17 +126,17 @@ describe("Map with one object and alternate array", () => {
126
126
assert ( arrayStringMap . has ( sampleArray2 ) ) ;
127
127
} )
128
128
it ( "Map entries returns array with one object" , ( ) => {
129
- assert ( [ ...arrayStringMap . entries ( ) ] . length === 1 ) ;
130
- assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 0 ] === sampleArray2 ) ;
131
- assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 1 ] === sampleValue2 ) ;
129
+ assert ( [ ...arrayStringMap . entries ( ) ] . length === 1 , "Array length is 1" ) ;
130
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 0 ] === sampleArray2 , "Array is sampleArray2" ) ;
131
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 1 ] === sampleValue2 , "Value is sampleValue2" ) ;
132
132
} )
133
133
it ( "Map keys returns array with one object" , ( ) => {
134
- assert ( [ ...arrayStringMap . keys ( ) ] . length === 1 ) ;
135
- assert ( [ ...arrayStringMap . keys ( ) ] [ 0 ] === sampleArray2 ) ;
134
+ assert ( [ ...arrayStringMap . keys ( ) ] . length === 1 , "Array length is 1" ) ;
135
+ assert ( [ ...arrayStringMap . keys ( ) ] [ 0 ] === sampleArray2 , "Array is sampleArray2" ) ;
136
136
} )
137
137
it ( "Map values returns array with one value" , ( ) => {
138
- assert ( [ ...arrayStringMap . values ( ) ] . length === 1 ) ;
139
- assert ( [ ...arrayStringMap . values ( ) ] [ 0 ] === sampleValue2 ) ;
138
+ assert ( [ ...arrayStringMap . values ( ) ] . length === 1 , "Array length is 1" ) ;
139
+ assert ( [ ...arrayStringMap . values ( ) ] [ 0 ] === sampleValue2 , "Value is sampleValue2" ) ;
140
140
} )
141
141
} )
142
142
@@ -148,75 +148,77 @@ describe("Map with two objects", () => {
148
148
assert ( arrayStringMap . size === 2 ) ;
149
149
} )
150
150
it ( "Map get returns value" , ( ) => {
151
- assert ( arrayStringMap . get ( sampleArray1 ) === sampleValue1 ) ;
152
- assert ( arrayStringMap . get ( sampleArray3 ) === sampleValue2 ) ;
151
+ assert ( arrayStringMap . get ( sampleArray1 ) === sampleValue1 , "Value is sampleValue1" ) ;
152
+ assert ( arrayStringMap . get ( sampleArray3 ) === sampleValue2 , "Value is sampleValue2" ) ;
153
153
} )
154
154
it ( "Alternate array with same values returns same value" , ( ) => {
155
- assert ( arrayStringMap . get ( sampleArray2 ) === sampleValue1 ) ;
156
- assert ( arrayStringMap . get ( sampleArray3 ) !== sampleValue1 ) ;
155
+ assert ( arrayStringMap . get ( sampleArray2 ) === sampleValue1 , "Value is sampleValue1" ) ;
156
+ assert ( arrayStringMap . get ( sampleArray3 ) !== sampleValue1 , "Value is not sampleValue1" ) ;
157
157
} )
158
158
it ( "Map has returns true" , ( ) => {
159
- assert ( arrayStringMap . has ( sampleArray1 ) ) ;
160
- assert ( arrayStringMap . has ( sampleArray2 ) ) ;
159
+ assert ( arrayStringMap . has ( sampleArray1 ) , "Has for sampleArray1 returns true" ) ;
160
+ assert ( arrayStringMap . has ( sampleArray2 ) , "Has for sampleArray2 returns true" ) ;
161
161
} )
162
162
it ( "Map entries returns array with two objects" , ( ) => {
163
- assert ( [ ...arrayStringMap . entries ( ) ] . length === 2 ) ;
164
- assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 0 ] === sampleArray1 ) ;
165
- assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 1 ] === sampleValue1 ) ;
166
- assert ( [ ...arrayStringMap . entries ( ) ] [ 1 ] [ 0 ] === sampleArray3 ) ;
167
- assert ( [ ...arrayStringMap . entries ( ) ] [ 1 ] [ 1 ] === sampleValue2 ) ;
163
+ assert ( [ ...arrayStringMap . entries ( ) ] . length === 2 , "Array length is 2" ) ;
164
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 0 ] === sampleArray1 , "Array is sampleArray1" ) ;
165
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 0 ] [ 1 ] === sampleValue1 , "Value is sampleValue1" ) ;
166
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 1 ] [ 0 ] === sampleArray3 , "Array is sampleArray3" ) ;
167
+ assert ( [ ...arrayStringMap . entries ( ) ] [ 1 ] [ 1 ] === sampleValue2 , "Value is sampleValue2" ) ;
168
168
} )
169
169
it ( "Map keys returns array with two objects" , ( ) => {
170
- assert ( [ ...arrayStringMap . keys ( ) ] . length === 2 ) ;
171
- assert ( [ ...arrayStringMap . keys ( ) ] [ 0 ] === sampleArray1 ) ;
172
- assert ( [ ...arrayStringMap . keys ( ) ] [ 1 ] === sampleArray3 ) ;
170
+ assert ( [ ...arrayStringMap . keys ( ) ] . length === 2 , "Array length is 2" ) ;
171
+ assert ( [ ...arrayStringMap . keys ( ) ] [ 0 ] === sampleArray1 , "Array is sampleArray1" ) ;
172
+ assert ( [ ...arrayStringMap . keys ( ) ] [ 1 ] === sampleArray3 , "Array is sampleArray3" ) ;
173
173
} )
174
174
it ( "Map values returns array with two values" , ( ) => {
175
- assert ( [ ...arrayStringMap . values ( ) ] . length === 1 ) ;
176
- assert ( [ ...arrayStringMap . values ( ) ] [ 0 ] === sampleValue1 ) ;
175
+ assert ( [ ...arrayStringMap . values ( ) ] . length === 1 , "Array length is 1" ) ;
176
+ assert ( [ ...arrayStringMap . values ( ) ] [ 0 ] === sampleValue1 , "Value is sampleValue1" ) ;
177
177
} )
178
178
it ( "Map uses proper separator underneath" , ( ) => {
179
179
// @ts -ignore - this is a test, and we need to make sure the underlying map
180
180
// works as expected
181
- assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 0 ] . includes ( "\u200b" ) ) ;
181
+ assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 0 ] . includes ( "\u200b" ) , "Separator is present in item 0" ) ;
182
182
// @ts -ignore - this is a test, and we need to make sure the underlying map
183
183
// works as expected
184
- assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 1 ] . includes ( "\u200b" ) ) ;
184
+ assert ( [ ...arrayStringMap . _map . keys ( ) ] [ 1 ] . includes ( "\u200b" ) , "Separator is present in item 1" ) ;
185
185
// @ts -ignore - this is a test, and we need to make sure the underlying encoding map
186
186
// works as expected
187
- assert ( [ ...arrayStringMap . _converterInfo . values ( ) ] [ 0 ] === sampleArray1 ) ;
187
+ assert ( [ ...arrayStringMap . _converterInfo . values ( ) ] [ 0 ] === sampleArray1 , "Converter info is sampleArray1 for item 0" ) ;
188
188
// @ts -ignore - this is a test, and we need to make sure the underlying map
189
189
// works as expected
190
- assert ( [ ...arrayStringMap . _converterInfo . values ( ) ] [ 1 ] === sampleArray3 ) ;
190
+ assert ( [ ...arrayStringMap . _converterInfo . values ( ) ] [ 1 ] === sampleArray3 , "Converter info is sampleArray3 for item 1" ) ;
191
191
} )
192
192
it ( "Clearing map removes all objects" , ( ) => {
193
193
const copiedMap = copyArrayStringMap ( arrayStringMap ) ;
194
194
copiedMap . clear ( ) ;
195
- assert ( copiedMap . size === 0 ) ;
196
- assert ( copiedMap . get ( sampleArray1 ) === undefined ) ;
197
- assert ( ! copiedMap . has ( sampleArray1 ) ) ;
198
- assert ( [ ...copiedMap . entries ( ) ] . length === 0 ) ;
195
+ assert ( copiedMap . size === 0 , "Map size is 0" ) ;
196
+ assert ( copiedMap . get ( sampleArray1 ) === undefined , "Map get returns undefined for sampleArray1" ) ;
197
+ assert ( copiedMap . get ( sampleArray3 ) === undefined , "Map get returns undefined for sampleArray3" ) ;
198
+ assert ( ! copiedMap . has ( sampleArray1 ) , "Map has returns false for sampleArray1" ) ;
199
+ assert ( ! copiedMap . has ( sampleArray3 ) , "Map has returns false for sampleArray3" ) ;
200
+ assert ( [ ...copiedMap . entries ( ) ] . length === 0 , "Map entries returns empty array" ) ;
199
201
// @ts -ignore - this is a test, and we need to make sure the underlying map
200
202
// works as expected
201
- assert ( copiedMap . _map . size === 0 ) ;
203
+ assert ( copiedMap . _map . size === 0 , "Data map size is 0" ) ;
202
204
// @ts -ignore - this is a test, and we need to make sure the underlying encoding map
203
205
// works as expected
204
- assert ( copiedMap . _converterInfo . size === 0 ) ;
206
+ assert ( copiedMap . _converterInfo . size === 0 , "Converter map size is 0" ) ;
205
207
} )
206
208
it ( "Deleting entry from map removes object but keeps other object" , ( ) => {
207
209
const copiedMap = copyArrayStringMap ( arrayStringMap ) ;
208
210
copiedMap . delete ( sampleArray1 ) ;
209
- assert ( copiedMap . size === 1 ) ;
210
- assert ( copiedMap . get ( sampleArray1 ) === undefined ) ;
211
- assert ( copiedMap . get ( sampleArray3 ) === sampleValue2 ) ;
212
- assert ( ! copiedMap . has ( sampleArray1 ) ) ;
213
- assert ( copiedMap . has ( sampleArray3 ) ) ;
214
- assert ( [ ...copiedMap . entries ( ) ] . length === 1 ) ;
211
+ assert ( copiedMap . size === 1 , "Map size is 1" ) ;
212
+ assert ( copiedMap . get ( sampleArray1 ) === undefined , "Map get returns undefined for sampleArray1" ) ;
213
+ assert ( copiedMap . get ( sampleArray3 ) === sampleValue2 , "Map get returns sampleValue2 for sampleArray3" ) ;
214
+ assert ( ! copiedMap . has ( sampleArray1 ) , "Map has returns false for sampleArray1" ) ;
215
+ assert ( copiedMap . has ( sampleArray3 ) , "Map has returns true for sampleArray3" ) ;
216
+ assert ( [ ...copiedMap . entries ( ) ] . length === 1 , "Map entries returns array with one object" ) ;
215
217
// @ts -ignore - this is a test, and we need to make sure the underlying map
216
218
// works as expected
217
- assert ( copiedMap . _map . size === 1 ) ;
219
+ assert ( copiedMap . _map . size === 1 , "Data map size is 1" ) ;
218
220
// @ts -ignore - this is a test, and we need to make sure the underlying encoding map
219
221
// works as expected
220
- assert ( copiedMap . _converterInfo . size === 1 ) ;
222
+ assert ( copiedMap . _converterInfo . size === 1 , "Converter map size is 1" ) ;
221
223
} )
222
224
} )
0 commit comments