diff options
author | 杨宇千 <crupest@outlook.com> | 2019-04-11 20:02:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-11 20:02:33 +0800 |
commit | 5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95 (patch) | |
tree | 695f7fc0bd2f6d940f64739a1f1f500c36806cef /Timeline/ClientApp/src/app/test-utilities/storage.mock.ts | |
parent | 1c9edc5914869a3bbde20742c483182636ee4d43 (diff) | |
parent | c28941c6d86f8ea33521bba49d811bf3ff60b3d1 (diff) | |
download | timeline-5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95.tar.gz timeline-5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95.tar.bz2 timeline-5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95.zip |
Merge pull request #17 from crupest/15-user
Remember me and log out feature.
Diffstat (limited to 'Timeline/ClientApp/src/app/test-utilities/storage.mock.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/test-utilities/storage.mock.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Timeline/ClientApp/src/app/test-utilities/storage.mock.ts b/Timeline/ClientApp/src/app/test-utilities/storage.mock.ts new file mode 100644 index 00000000..0ba5aa35 --- /dev/null +++ b/Timeline/ClientApp/src/app/test-utilities/storage.mock.ts @@ -0,0 +1,28 @@ +import { Mock } from './mock'; +import { nullIfUndefined } from '../utilities/language-untilities'; + +export function createMockStorage(): Mock<Storage> { + const map: { [key: string]: string } = {}; + return { + get length(): number { + return Object.keys(map).length; + }, + key(index: number): string | null { + const keys = Object.keys(map); + if (index >= keys.length) { return null; } + return keys[index]; + }, + clear() { + Object.keys(map).forEach(key => delete map.key); + }, + getItem(key: string): string | null { + return nullIfUndefined(map[key]); + }, + setItem(key: string, value: string) { + map[key] = value; + }, + removeItem(key: string) { + delete map[key]; + } + }; +} |