Skip to content

Commit

Permalink
Add logout e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBartusek committed Apr 30, 2024
1 parent 8003d20 commit 129a52a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apps/api/test/auth.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('AuthController (e2e)', () => {
let app: NestExpressApplication;
let agent: request.SuperAgentTest;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
Expand All @@ -23,9 +23,13 @@ describe('AuthController (e2e)', () => {
it('/auth/register (POST)', async () => {
const payload = { username: 'test-user', email: '[email protected]', password: 'Test123!' };

const test = await agent.post('/api/auth/register').send(payload).expect(200);

expect(test.body.email).toBe('[email protected]');
return agent
.post('/api/auth/register')
.send(payload)
.expect(200)
.then((res) => {
expect(res.body.email).toBe('[email protected]');
});
});

it('/auth/login (POST)', async () => {
Expand All @@ -37,4 +41,8 @@ describe('AuthController (e2e)', () => {
.expect('set-cookie', /connect.sid/)
.expect(200);
});

it('/auth/logout (POST)', async () => {
return agent.post('/api/auth/logout').expect(200);
});
});

0 comments on commit 129a52a

Please sign in to comment.