mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { INestApplication, ValidationPipe } from '@nestjs/common';
|
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
import request from 'supertest';
|
|
import { AppModule } from '../src/app.module';
|
|
|
|
describe('Passenger API (e2e)', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeAll(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
}).compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
|
|
await app.init();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
|
|
it('GET /stations returns 200', () => {
|
|
return request(app.getHttpServer()).get('/stations').expect(200);
|
|
});
|
|
|
|
it('GET /search returns 200', () => {
|
|
return request(app.getHttpServer()).get('/search').expect(404); // POST only
|
|
});
|
|
|
|
it('POST /auth/login with bad credentials returns 401', () => {
|
|
return request(app.getHttpServer())
|
|
.post('/auth/login')
|
|
.send({ email: 'nobody@test.com', password: 'wrong' })
|
|
.expect(401);
|
|
});
|
|
});
|