Created
April 18, 2019 21:18
-
-
Save intech/e2e47310a8a48c766c1472272c5ba802 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| describe("Test route.path and aliases", () => { | |
| let broker; | |
| let app; | |
| let service; | |
| let nextHandler = jest.fn((req, res) => res.sendStatus(200)); | |
| beforeAll(() => { | |
| broker = new ServiceBroker({ logger: false }); | |
| service = broker.createService(ApiGateway, { | |
| settings: { | |
| path: "/api", | |
| routes: [{ | |
| path: "/te", | |
| aliases: { | |
| "GET test"(req, res) { | |
| res.end("/api/te/test"); | |
| } | |
| } | |
| },{ | |
| path: "", | |
| aliases: { | |
| "GET test"(req, res) { | |
| res.end("/api/test"); | |
| } | |
| } | |
| }] | |
| } | |
| }); | |
| return broker.start(); | |
| }); | |
| afterAll(() => { | |
| return broker.stop(); | |
| }); | |
| it("GET /api/te/test", () => { | |
| return request(service.server) | |
| .get("/api/te/test") | |
| .then(res => { | |
| console.log(res.body); | |
| expect(res.statusCode).toBe(200); | |
| expect(res.text).toBe("/api/te/test"); | |
| expect(nextHandler).toHaveBeenCalledTimes(0); | |
| }); | |
| }); | |
| it("GET /api/test", () => { | |
| return request(service.server) | |
| .get("/api/test") | |
| .then(res => { | |
| console.log(res.body); | |
| expect(res.statusCode).toBe(200); | |
| expect(res.text).toBe("/api/test"); | |
| expect(nextHandler).toHaveBeenCalledTimes(0); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment