UNPKG

@tsed/platform-test-sdk

Version:
40 lines (39 loc) 1.28 kB
import { __decorate, __metadata } from "tslib"; import { Controller } from "@tsed/di"; import { PlatformTest } from "@tsed/platform-http/testing"; import { Get, Location } from "@tsed/schema"; import SuperTest from "supertest"; import { afterAll, beforeAll, expect, it } from "vitest"; let LocationCtrl = class LocationCtrl { testScenario1() { return "Hello"; } }; __decorate([ Get("/scenario-1"), Location("/test"), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], LocationCtrl.prototype, "testScenario1", null); LocationCtrl = __decorate([ Controller("/location") ], LocationCtrl); export function testLocation(options) { let request; beforeAll(PlatformTest.bootstrap(options.server, { ...options, mount: { "/rest": [LocationCtrl] } })); beforeAll(() => { request = SuperTest(PlatformTest.callback()); }); afterAll(PlatformTest.reset); it("Scenario1: GET /rest/location/scenario-1", async () => { const response = await request.get("/rest/location/scenario-1").expect(200); expect(response.text).toEqual("Hello"); expect(response.header.location).toEqual("/test"); }); }