53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import request from 'supertest';
|
|
import { AppModule } from './../src/app.module';
|
|
|
|
describe('AdminController (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('/admin/stats (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/admin/stats')
|
|
.expect(200)
|
|
.expect(res => {
|
|
expect(res.body).toHaveProperty('totalCompanies');
|
|
expect(res.body).toHaveProperty('monthlyRevenue');
|
|
});
|
|
});
|
|
|
|
it('/admin/revenue (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/admin/revenue')
|
|
.expect(200)
|
|
.expect(res => {
|
|
expect(Array.isArray(res.body)).toBe(true);
|
|
expect(res.body[0]).toHaveProperty('month');
|
|
expect(res.body[0]).toHaveProperty('revenue');
|
|
});
|
|
});
|
|
|
|
it('/admin/subscriptions-by-plan (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/admin/subscriptions-by-plan')
|
|
.expect(200)
|
|
.expect(res => {
|
|
expect(Array.isArray(res.body)).toBe(true);
|
|
expect(res.body[0]).toHaveProperty('plan');
|
|
expect(res.body[0]).toHaveProperty('count');
|
|
});
|
|
});
|
|
});
|