-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
381 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { execute } from "./RequestParser"; | ||
import { $setConfig } from "../../../src/application/variable/Config"; | ||
|
||
describe("RequestParserTest", () => | ||
{ | ||
test("request parse no match test case1", () => | ||
{ | ||
// mock | ||
const config = { | ||
"platform": "web", | ||
"spa": true, | ||
"stage": { | ||
"width": 240, | ||
"height": 240, | ||
"fps": 12, | ||
"options": {} | ||
}, | ||
"routing": {} | ||
}; | ||
|
||
$setConfig(config); | ||
|
||
const requests: Object[] = execute("top"); | ||
expect(requests.length).toBe(0); | ||
}); | ||
|
||
test("request parse no match test case2", () => | ||
{ | ||
// mock | ||
const config = { | ||
"platform": "web", | ||
"spa": true, | ||
"stage": { | ||
"width": 240, | ||
"height": 240, | ||
"fps": 12, | ||
"options": {} | ||
}, | ||
"routing": { | ||
"top": {} | ||
} | ||
}; | ||
|
||
$setConfig(config); | ||
|
||
const requests: Object[] = execute("top"); | ||
expect(requests.length).toBe(0); | ||
}); | ||
|
||
test("request parse match test case1", () => | ||
{ | ||
// mock | ||
const config = { | ||
"platform": "web", | ||
"spa": true, | ||
"stage": { | ||
"width": 240, | ||
"height": 240, | ||
"fps": 12, | ||
"options": {} | ||
}, | ||
"routing": { | ||
"top": { | ||
"requests": [ | ||
{ | ||
"type": "json", | ||
"name": "TopTest", | ||
"path": "local" | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
|
||
$setConfig(config); | ||
|
||
const requests: Object[] = execute("top"); | ||
expect(requests.length).toBe(1); | ||
|
||
const object: Object = requests[0]; | ||
expect(object.type).toBe("json"); | ||
expect(object.name).toBe("TopTest"); | ||
expect(object.path).toBe("local"); | ||
}); | ||
|
||
test("request parse cluster test case1", () => | ||
{ | ||
// mock | ||
const config = { | ||
"platform": "web", | ||
"spa": true, | ||
"stage": { | ||
"width": 240, | ||
"height": 240, | ||
"fps": 12, | ||
"options": {} | ||
}, | ||
"routing": { | ||
"@sample": { | ||
"requests": [ | ||
{ | ||
"type": "content", | ||
"path": "{{ content.endPoint }}content/sample.json", | ||
"name": "MainContent", | ||
"cache": true | ||
} | ||
] | ||
}, | ||
"top": { | ||
"requests": [ | ||
{ | ||
"type": "cluster", | ||
"path": "@sample" | ||
}, | ||
{ | ||
"type": "json", | ||
"path": "{{ api.endPoint }}api/top.json", | ||
"name": "TopText" | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
|
||
$setConfig(config); | ||
|
||
const requests: Object[] = execute("top"); | ||
expect(requests.length).toBe(2); | ||
|
||
const object1: Object = requests[0]; | ||
expect(object1.type).toBe("content"); | ||
expect(object1.name).toBe("MainContent"); | ||
|
||
const object2: Object = requests[1]; | ||
expect(object2.type).toBe("json"); | ||
expect(object2.name).toBe("TopText"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.