|
@@ -74,6 +74,23 @@ describe('ArrayStorage', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('getStorageId', () => {
|
|
|
+ const storageIdRegExp: RegExp = /^[a-zA-Z0-9]{6}$/;
|
|
|
+
|
|
|
+ let storageId: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ storage = getStorageInstance<string>();
|
|
|
+ storage.set(storageKey, storageValue);
|
|
|
+
|
|
|
+ storageId = storage.getStorageId();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return storage id', () => {
|
|
|
+ assert.match(storageId, storageIdRegExp);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('get', () => {
|
|
|
describe('Variant #1: value exist', () => {
|
|
|
const expectedValue: string = storageValue;
|
|
@@ -194,27 +211,62 @@ describe('ArrayStorage', () => {
|
|
|
});
|
|
|
|
|
|
describe('mergeWith', () => {
|
|
|
- const secondStorageKey: number = 1;
|
|
|
- const secondStorageValue: string = 'bar';
|
|
|
+ describe('Base merge', () => {
|
|
|
+ const secondStorageKey: number = 1;
|
|
|
+ const secondStorageValue: string = 'bar';
|
|
|
|
|
|
- const expectedArray: string[] = [storageValue, secondStorageValue];
|
|
|
+ const expectedArray: string[] = [storageValue, secondStorageValue];
|
|
|
|
|
|
- let array: string[];
|
|
|
+ let array: string[];
|
|
|
|
|
|
- before(() => {
|
|
|
- storage = getStorageInstance<string>();
|
|
|
- storage.set(storageKey, storageValue);
|
|
|
+ before(() => {
|
|
|
+ storage = getStorageInstance<string>();
|
|
|
+ storage.set(storageKey, storageValue);
|
|
|
|
|
|
- const secondStorage: IArrayStorage <string> = getStorageInstance<string>();
|
|
|
- secondStorage.set(secondStorageKey, secondStorageValue);
|
|
|
+ const secondStorage: IArrayStorage <string> = getStorageInstance<string>();
|
|
|
+ secondStorage.set(secondStorageKey, secondStorageValue);
|
|
|
|
|
|
- storage.mergeWith(secondStorage, false);
|
|
|
+ storage.mergeWith(secondStorage, false);
|
|
|
|
|
|
- array = storage.getStorage();
|
|
|
+ array = storage.getStorage();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should merge two storages', () => {
|
|
|
+ assert.deepEqual(array, expectedArray);
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
- it('should merge two storages', () => {
|
|
|
- assert.deepEqual(array, expectedArray);
|
|
|
+ describe('Merge with storage id', () => {
|
|
|
+ const secondStorageKey: number = 1;
|
|
|
+ const secondStorageValue: string = 'bar';
|
|
|
+
|
|
|
+ const expectedArray: string[] = [storageValue, secondStorageValue];
|
|
|
+
|
|
|
+ let array: string[];
|
|
|
+ let storageId: string;
|
|
|
+ let expectedStorageId: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ storage = getStorageInstance<string>();
|
|
|
+ storage.set(storageKey, storageValue);
|
|
|
+
|
|
|
+ const secondStorage: IArrayStorage <string> = getStorageInstance<string>();
|
|
|
+ expectedStorageId = secondStorage.getStorageId();
|
|
|
+ secondStorage.set(secondStorageKey, secondStorageValue);
|
|
|
+
|
|
|
+ storage.mergeWith(secondStorage, true);
|
|
|
+
|
|
|
+ storageId = storage.getStorageId();
|
|
|
+ array = storage.getStorage();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should update storage id', () => {
|
|
|
+ assert.deepEqual(storageId, expectedStorageId);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should merge two storages', () => {
|
|
|
+ assert.deepEqual(array, expectedArray);
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
});
|