Skip to content

Commit

Permalink
MAT 6727 add e2e test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-prateekkeerthi committed Mar 19, 2024
1 parent 8833bfa commit 24f2799
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/export.module';
import { ExportModule } from '../src/export.module';

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

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

app = moduleFixture.createNestApplication();
Expand All @@ -17,8 +17,23 @@ describe('AppController (e2e)', () => {

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.get('/excel')
.set(
'authorization',
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.kcPmFlSUdC9LvuMufomQepInu3GwbBKKct49e2dxyrI',
)
.expect(200)
.expect('Hello World!');
.expect(
'Content-Type',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
);
});

it('/ (GET) unauthorized', () => {
return request(app.getHttpServer()).get('/excel').expect(401).expect({
message: 'Token not present',
error: 'Unauthorized',
statusCode: 401,
});
});
});

0 comments on commit 24f2799

Please sign in to comment.