gohorsejobs/backoffice/test/plans.e2e-spec.ts

44 lines
1.3 KiB
TypeScript

import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { AppModule } from './../src/app.module';
describe('PlansController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
afterEach(async () => {
await app.close();
});
it('/plans (GET)', () => {
return request(app.getHttpServer())
.get('/plans')
.expect(200)
.expect(res => {
expect(Array.isArray(res.body)).toBe(true);
expect(res.body.length).toBeGreaterThan(0);
expect(res.body[0]).toHaveProperty('id');
expect(res.body[0]).toHaveProperty('name');
expect(res.body[0]).toHaveProperty('monthlyPrice');
});
});
it('/plans/:id (GET)', () => {
return request(app.getHttpServer())
.get('/plans/starter')
.expect(200)
.expect(res => {
expect(res.body.id).toBe('starter');
expect(res.body.name).toBe('Starter');
});
});
});