Skip to content

Commit

Permalink
test: 11번 채점 테스트 케이스 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
flydog98 authored and LuizyHub committed Dec 4, 2023
1 parent 55233f3 commit d6b0430
Showing 1 changed file with 129 additions and 0 deletions.
129 changes: 129 additions & 0 deletions packages/backend/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,135 @@ describe('QuizWizardController (e2e)', () => {
});
});

describe('11번 문제 채점 테스트', () => {
const id = 11;
afterEach(async () => {
await request(app.getHttpServer())
.delete(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie);
});

it('베스트 성공 케이스', async () => {
response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.send({
mode: 'command',
message: 'git stash',
});

cookie = response.headers['set-cookie'][0].split(';')[0];

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie)
.send({
mode: 'command',
message: 'git checkout 55f7aab2f31287f6bb159731e5824566c02b582b',
});

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie)
.send({
mode: 'command',
message: 'git switch -c hotfix/fixA',
});

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/submit`)
.set('Cookie', cookie)
.expect(200);

expect(response.body).toHaveProperty('solved', true);
});

it('체크아웃 한 다음에 stash', async () => {
response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.send({
mode: 'command',
message: 'git checkout 55f7aab2f31287f6bb159731e5824566c02b582b',
});

cookie = response.headers['set-cookie'][0].split(';')[0];

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie)
.send({
mode: 'command',
message: 'git stash',
});

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie)
.send({
mode: 'command',
message: 'git switch -c hotfix/fixA',
});

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/submit`)
.set('Cookie', cookie)
.expect(200);

expect(response.body).toHaveProperty('solved', false);
});

it('브랜치 만들 때 실수하는 케이스', async () => {
response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.send({
mode: 'command',
message: 'git stash',
});

cookie = response.headers['set-cookie'][0].split(';')[0];

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie)
.send({
mode: 'command',
message: 'git checkout 55f7aab2f31287f6bb159731e5824566c02b582b',
});

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.set('Cookie', cookie)
.send({
mode: 'command',
message: 'git switch hotfix/fixA',
});

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/submit`)
.set('Cookie', cookie)
.expect(200);

expect(response.body).toHaveProperty('solved', false);
});

it('아무것도 안 하고 채점', async () => {
response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/command`)
.send({
mode: 'command',
message: 'git status',
});

cookie = response.headers['set-cookie'][0].split(';')[0];

response = await request(app.getHttpServer())
.post(`/api/v1/quizzes/${id}/submit`)
.set('Cookie', cookie)
.expect(200);

expect(response.body).toHaveProperty('solved', false);
});
});

describe('12번 문제 채점 테스트', () => {
const id = 12;
afterEach(async () => {
Expand Down

0 comments on commit d6b0430

Please sign in to comment.