Skip to content

Commit

Permalink
- Add a test to ensure that we can load a route at the root.
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennenoel authored Sep 24, 2024
1 parent a845dcd commit 95bb937
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/e2e/scenarios/modules/networking/controllers.scenario.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,23 @@ describe("Networking - Controllers", () => {
expect(response instanceof Response).toBeTruthy()
expect(response.status).toBe(200);
})

it("should load the 'nested' controller", async () => {
const kernel = new Kernel();
await kernel.start(testModule, {
"pristine.logging.consoleLoggerActivated": false,
"pristine.logging.fileLoggerActivated": false,
});

const request = new Request(HttpMethod.Get, "https://localhost:8080/api/2.0/magieno/pristine");

const response = await kernel.handle(request, {
keyname: ExecutionContextKeynameEnum.Jest,
context: {}
}) as Response;

expect(response instanceof Response).toBeTruthy()
expect(response.status).toBe(200);
expect(response.body).toStrictEqual({"NestedController": true});
})
})
11 changes: 11 additions & 0 deletions tests/e2e/src/controllers/nested.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {controller, route, body, routeParameter} from "@pristine-ts/networking";
import {HttpMethod} from "@pristine-ts/common";


@controller("/api/2.0/magieno/pristine")
export class NestedController {
@route(HttpMethod.Get, "")
get() {
return {"NestedController": true}
}
}
3 changes: 2 additions & 1 deletion tests/e2e/src/test.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {InjectedClass} from "./models/injected-class.model";
import {Voter1Model} from "./models/voter1.model";
import {Voter2Model} from "./models/voter2.model";
import {TestController} from "./controllers/test.controller";
import {NestedController} from "./controllers/nested.controller";
import {TestGuard} from "./guards/test.guard";
import {SecurityModule} from "@pristine-ts/security";
import {AppModuleInterface} from "@pristine-ts/common";
import {NetworkingModule} from "@pristine-ts/networking";

export const testModule: AppModuleInterface = {
keyname: "test",
importServices: [TestController],
importServices: [TestController, NestedController],
importModules: [CoreModule, SecurityModule, NetworkingModule],
providerRegistrations: [
{
Expand Down

0 comments on commit 95bb937

Please sign in to comment.