Skip to content

Commit

Permalink
Merge pull request #11336 from qmonmert/typo101124
Browse files Browse the repository at this point in the history
Typo
  • Loading branch information
murdos authored Nov 10, 2024
2 parents 07ebdc4 + c920297 commit affda53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ModuleParameterType } from '../domain/ModuleParameters';
import { ModuleParametersRepository } from '../domain/ModuleParametersRepository';

const STORAGE_KEY_MODULE_PARAMETERS_SUFIX = '_moduleParameters';
const STORAGE_KEY_MODULE_PARAMETERS_SUFFIX = '_moduleParameters';
const STORAGE_KEY_CURRENT_FOLDER_PATH = 'currentFolderPath';

export class LocalStorageModuleParametersRepository implements ModuleParametersRepository {
Expand All @@ -13,12 +13,12 @@ export class LocalStorageModuleParametersRepository implements ModuleParametersR
}

store(folderPath: string, map: Map<string, ModuleParameterType>): void {
this.localStorage.setItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFIX, JSON.stringify(Array.from(map.entries())));
this.localStorage.setItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX, JSON.stringify(Array.from(map.entries())));
}

get(folderPath: string): Map<string, ModuleParameterType> {
this.localStorage.setItem(STORAGE_KEY_CURRENT_FOLDER_PATH, folderPath);
const storedValue = this.localStorage.getItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFIX);
const storedValue = this.localStorage.getItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX);
if (storedValue) {
return new Map(JSON.parse(storedValue));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const fakeStorage = (): Storage => {
};
};

const STORAGE_KEY_MODULE_PARAMETERS_SUFIX = '_moduleParameters';
const STORAGE_KEY_MODULE_PARAMETERS_SUFFIX = '_moduleParameters';
const STORAGE_KEY_CURRENT_FOLDER_PATH = 'currentFolderPath';

describe('LocalStorageModuleParametersRepository', () => {
Expand All @@ -32,7 +32,7 @@ describe('LocalStorageModuleParametersRepository', () => {

repo.store(folderPath, new Map(data));

expect(JSON.parse(storage.getItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFIX)!)).toEqual(data);
expect(JSON.parse(storage.getItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX)!)).toEqual(data);
});

it('should return empty Map when there is not module parameters in localStorage', () => {
Expand All @@ -55,7 +55,7 @@ describe('LocalStorageModuleParametersRepository', () => {
storage.clear();
const repo = new LocalStorageModuleParametersRepository(storage);

storage.setItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFIX, JSON.stringify(Array.from(data)));
storage.setItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX, JSON.stringify(Array.from(data)));

expect(repo.get(folderPath)).toEqual(new Map(data));
});
Expand All @@ -73,12 +73,12 @@ describe('LocalStorageModuleParametersRepository', () => {
];
const storage = fakeStorage();
storage.clear();
storage.setItem(folderPathOne + STORAGE_KEY_MODULE_PARAMETERS_SUFIX, JSON.stringify(Array.from(dataOne)));
storage.setItem(folderPathOne + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX, JSON.stringify(Array.from(dataOne)));
const repo = new LocalStorageModuleParametersRepository(storage);

repo.store(folderPathTwo, new Map(dataTwo));

expect(JSON.parse(storage.getItem(folderPathOne + STORAGE_KEY_MODULE_PARAMETERS_SUFIX)!)).toEqual(dataOne);
expect(JSON.parse(storage.getItem(folderPathOne + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX)!)).toEqual(dataOne);
});

it('should remove current folder path from localStorage when the constructor is called', () => {
Expand All @@ -104,7 +104,7 @@ describe('LocalStorageModuleParametersRepository', () => {
['key1', 'value1'],
['key2', 'value2'],
];
storage.setItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFIX, JSON.stringify(Array.from(data)));
storage.setItem(folderPath + STORAGE_KEY_MODULE_PARAMETERS_SUFFIX, JSON.stringify(Array.from(data)));

repo.get(folderPath);

Expand Down

0 comments on commit affda53

Please sign in to comment.