@@ -74,6 +74,23 @@ describe('ArrayStorage', () => {
74
74
} ) ;
75
75
} ) ;
76
76
77
+ describe ( 'getStorageId' , ( ) => {
78
+ const storageIdRegExp : RegExp = / ^ [ a - z A - Z 0 - 9 ] { 6 } $ / ;
79
+
80
+ let storageId : string ;
81
+
82
+ before ( ( ) => {
83
+ storage = getStorageInstance < string > ( ) ;
84
+ storage . set ( storageKey , storageValue ) ;
85
+
86
+ storageId = storage . getStorageId ( ) ;
87
+ } ) ;
88
+
89
+ it ( 'should return storage id' , ( ) => {
90
+ assert . match ( storageId , storageIdRegExp ) ;
91
+ } ) ;
92
+ } ) ;
93
+
77
94
describe ( 'get' , ( ) => {
78
95
describe ( 'Variant #1: value exist' , ( ) => {
79
96
const expectedValue : string = storageValue ;
@@ -194,27 +211,62 @@ describe('ArrayStorage', () => {
194
211
} ) ;
195
212
196
213
describe ( 'mergeWith' , ( ) => {
197
- const secondStorageKey : number = 1 ;
198
- const secondStorageValue : string = 'bar' ;
214
+ describe ( 'Base merge' , ( ) => {
215
+ const secondStorageKey : number = 1 ;
216
+ const secondStorageValue : string = 'bar' ;
199
217
200
- const expectedArray : string [ ] = [ storageValue , secondStorageValue ] ;
218
+ const expectedArray : string [ ] = [ storageValue , secondStorageValue ] ;
201
219
202
- let array : string [ ] ;
220
+ let array : string [ ] ;
203
221
204
- before ( ( ) => {
205
- storage = getStorageInstance < string > ( ) ;
206
- storage . set ( storageKey , storageValue ) ;
222
+ before ( ( ) => {
223
+ storage = getStorageInstance < string > ( ) ;
224
+ storage . set ( storageKey , storageValue ) ;
207
225
208
- const secondStorage : IArrayStorage < string > = getStorageInstance < string > ( ) ;
209
- secondStorage . set ( secondStorageKey , secondStorageValue ) ;
226
+ const secondStorage : IArrayStorage < string > = getStorageInstance < string > ( ) ;
227
+ secondStorage . set ( secondStorageKey , secondStorageValue ) ;
210
228
211
- storage . mergeWith ( secondStorage , false ) ;
229
+ storage . mergeWith ( secondStorage , false ) ;
212
230
213
- array = storage . getStorage ( ) ;
231
+ array = storage . getStorage ( ) ;
232
+ } ) ;
233
+
234
+ it ( 'should merge two storages' , ( ) => {
235
+ assert . deepEqual ( array , expectedArray ) ;
236
+ } ) ;
214
237
} ) ;
215
238
216
- it ( 'should merge two storages' , ( ) => {
217
- assert . deepEqual ( array , expectedArray ) ;
239
+ describe ( 'Merge with storage id' , ( ) => {
240
+ const secondStorageKey : number = 1 ;
241
+ const secondStorageValue : string = 'bar' ;
242
+
243
+ const expectedArray : string [ ] = [ storageValue , secondStorageValue ] ;
244
+
245
+ let array : string [ ] ;
246
+ let storageId : string ;
247
+ let expectedStorageId : string ;
248
+
249
+ before ( ( ) => {
250
+ storage = getStorageInstance < string > ( ) ;
251
+ storage . set ( storageKey , storageValue ) ;
252
+
253
+ const secondStorage : IArrayStorage < string > = getStorageInstance < string > ( ) ;
254
+ expectedStorageId = secondStorage . getStorageId ( ) ;
255
+ secondStorage . set ( secondStorageKey , secondStorageValue ) ;
256
+
257
+ storage . mergeWith ( secondStorage , true ) ;
258
+
259
+ storageId = storage . getStorageId ( ) ;
260
+ array = storage . getStorage ( ) ;
261
+ } ) ;
262
+
263
+ it ( 'should update storage id' , ( ) => {
264
+ assert . deepEqual ( storageId , expectedStorageId ) ;
265
+ } ) ;
266
+
267
+ it ( 'should merge two storages' , ( ) => {
268
+ assert . deepEqual ( array , expectedArray ) ;
269
+ } ) ;
218
270
} ) ;
219
271
} ) ;
220
272
} ) ;
0 commit comments