diff options
author | crupest <crupest@outlook.com> | 2019-03-09 23:40:06 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-09 23:40:06 +0800 |
commit | e72a1cc3f98e45aee6eb29d3281118fa8373233f (patch) | |
tree | 22bb24a7ecf57b694d131ec6e6f34ef8cce6bb0c /Timeline/ClientApp/src/app/user/mock-activated-route.ts | |
parent | 76300141a6411c05d585994d5f19938bfe45838e (diff) | |
download | timeline-e72a1cc3f98e45aee6eb29d3281118fa8373233f.tar.gz timeline-e72a1cc3f98e45aee6eb29d3281118fa8373233f.tar.bz2 timeline-e72a1cc3f98e45aee6eb29d3281118fa8373233f.zip |
Half work!
Diffstat (limited to 'Timeline/ClientApp/src/app/user/mock-activated-route.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/user/mock-activated-route.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Timeline/ClientApp/src/app/user/mock-activated-route.ts b/Timeline/ClientApp/src/app/user/mock-activated-route.ts new file mode 100644 index 00000000..9e516e83 --- /dev/null +++ b/Timeline/ClientApp/src/app/user/mock-activated-route.ts @@ -0,0 +1,43 @@ +import { ParamMap } from '@angular/router'; + +interface MockActivatedRoute { + snapshot: MockActivatedRouteSnapshot; +} + +interface MockActivatedRouteSnapshot { + paramMap: ParamMap; +} + +export function createMockActivatedRoute(mockParamMap: { [name: string]: string | string[] }): MockActivatedRoute { + return { + snapshot: { + paramMap: { + keys: Object.keys(mockParamMap), + get(name: string): string | null { + const param = mockParamMap[name]; + if (typeof param === 'string') { + return param; + } else if (param instanceof Array) { + if (param.length === 0) { + return null; + } + return param[0]; + } + return null; + }, + getAll(name: string): string[] { + const param = mockParamMap[name]; + if (typeof param === 'string') { + return [param]; + } else if (param instanceof Array) { + return param; + } + return []; + }, + has(name: string): boolean { + return mockParamMap.hasOwnProperty(name); + } + } + } + } +} |