This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
14 changed files
with
270 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Action, HttpResult } from "../../../../../../src"; | ||
|
||
export default class extends Action { | ||
async do(): Promise<HttpResult> { | ||
return this.ok({ | ||
method: "POST", | ||
action: "query/miss", | ||
realPath: this.realPath, | ||
}); | ||
} | ||
} |
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,11 @@ | ||
import { Action, HttpResult } from "../../../../../src"; | ||
|
||
export default class extends Action { | ||
async do(): Promise<HttpResult> { | ||
return this.ok({ | ||
method: "POST", | ||
action: "query", | ||
realPath: this.realPath, | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
test/controllers/restful/method/^query2/^nextQuery/post.ts
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,11 @@ | ||
import { Action, HttpResult } from "../../../../../../src"; | ||
|
||
export default class extends Action { | ||
async do(): Promise<HttpResult> { | ||
return this.ok({ | ||
method: "POST", | ||
action: "query2/nextQuery", | ||
realPath: this.realPath, | ||
}); | ||
} | ||
} |
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,11 @@ | ||
import { Action, HttpResult } from "../../../../../../src"; | ||
|
||
export default class extends Action { | ||
async do(): Promise<HttpResult> { | ||
return this.ok({ | ||
method: "POST", | ||
action: "miss/query", | ||
realPath: this.realPath, | ||
}); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
import { HttpMethod, Router } from "../../src/index"; | ||
|
||
test(`action name error`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/err", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(404); | ||
}); |
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,87 @@ | ||
import { HttpMethod, Router } from "../../src/index"; | ||
|
||
test(`find next`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
}); | ||
|
||
test(`find simple`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method/simple", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
expect((result.body as Record<string, string>).action).toBe("simple"); | ||
}); | ||
|
||
test(`find simple next`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method/any", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
expect((result.body as Record<string, string>).action).toBe("query"); | ||
}); | ||
|
||
test(`find miss next`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method/miss", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
expect((result.body as Record<string, string>).action).toBe("miss"); | ||
expect((result.body as Record<string, string>).action).not.toBe("query"); | ||
}); | ||
|
||
test(`find miss next 2`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method/miss/any", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
expect((result.body as Record<string, string>).action).toBe("miss/query"); | ||
}); | ||
|
||
test(`find miss next 3`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method/any/miss", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
expect((result.body as Record<string, string>).action).toBe("query/miss"); | ||
}); | ||
|
||
test(`find miss next 4`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful/method/any/any", | ||
httpMethod: HttpMethod.post, | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(200); | ||
expect((result.body as Record<string, string>).action).toBe( | ||
"query2/nextQuery" | ||
); | ||
}); |
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,12 @@ | ||
import { Router } from "../../src/index"; | ||
|
||
test(`method not allowed`, async function () { | ||
const event = { | ||
body: {}, | ||
path: "/restful", | ||
httpMethod: "NO", | ||
}; | ||
const router = new Router(event, {}, undefined, "test/controllers"); | ||
const result = (await router.do()).result; | ||
expect(result.statusCode).toBe(405); | ||
}); |
Oops, something went wrong.