Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
wip - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb-sti1 committed Sep 10, 2023
1 parent 03b0354 commit 3ebf5ef
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 8 deletions.
6 changes: 3 additions & 3 deletions backend/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('AppController', () => {
appController = app.get<AppController>(AppController);
});

describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
describe('GET /', () => {
it('should return "OK"', () => {
expect(appController.getStatus()).toBe('OK');
});
});
});
24 changes: 24 additions & 0 deletions backend/src/conditions/rc.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';

import { RCController } from './rc.controller';
import { RCService } from './rc.service';

describe('Road Condition Controller', () => {
let rcController: RCController;

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [RCController],
providers: [RCService],
}).compile();

rcController = app.get<RCController>(RCController);
});

describe('GET /', () => {
it('should return "OK"', () => {
expect(rcController).toBeDefined();;
});
});

});
11 changes: 6 additions & 5 deletions backend/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
import { AppModule } from "../src/app.module";

describe('AppController (e2e)', () => {

describe('App', () => {
let app: INestApplication;

beforeEach(async () => {
Expand All @@ -15,10 +16,10 @@ describe('AppController (e2e)', () => {
await app.init();
});

it('/ (GET)', () => {
it('GET /', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
.expect('OK');
});
});
});
50 changes: 50 additions & 0 deletions backend/test/rc.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from "../src/app.module";
import testJSON from "./utils";

describe('RoadConditions', () => {
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});

test('GET /conditions should return JSON', async () => {
const response = await request(app.getHttpServer())
.get('/conditions');

expect(response.status).toBe(200);
expect(testJSON(response.body)).not.toThrow();
});

/*
TODO: Need database to work
describe('GET /conditions/ways', () => {
it('Should return JSON', async () => {
const response = await request(app.getHttpServer())
.get('/conditions/ways?type=IRI&zoom=0');
expect(response.status).toBe(200);
expect(testJSON(response.body)).not.toThrow();
});
});
describe('GET /conditions/way', () => {
it('Should return JSON', async () => {
const response = await request(app.getHttpServer())
.get('/conditions/way?wayId=263681425&type=IRI');
expect(response.status).toBe(200);
expect(testJSON(response.body)).not.toThrow();
});
});
*/
});

0 comments on commit 3ebf5ef

Please sign in to comment.