Skip to content

Commit

Permalink
Imporve updateWordAcceptance.test.ts 187
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Feb 21, 2025
1 parent c16b884 commit 8296023
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/acceptance/languages/term/updateWordAcceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beforeAll, describe, beforeEach, afterAll, it, expect } from 'vitest';
import { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { MikroORM } from '@mikro-orm/core';
import { createApplication, truncateTables, USER_ID_LOGGED } from '@test/acceptance/createApplication';
import { createApplication, USER_ID_LOGGED } from '@test/acceptance/createApplication';
import WordMother from '@test/unit/languages/domain/term/word/wordMother';
import { TermIdMother } from '@test/unit/languages/domain/term/termIdMother';
import { CountryIdMother } from '@test/unit/languages/domain/country/countryIdMother';
Expand All @@ -13,6 +13,7 @@ import { UserIdMother } from '@test/unit/account/domain/user/userIdMother';
describe('Update word feature', () => {
let app: INestApplication;
let orm: MikroORM;
const TERM_ID = '744112be-3b9d-4d70-a242-9b275a1ce041';

const prepareApp = async () => {
const setup = await createApplication();
Expand All @@ -34,13 +35,9 @@ describe('Update word feature', () => {
});

describe('As a user I want to update a word', () => {
const wordId = TermIdMother.random().toString();

async function startScenario() {
await truncateTables(orm);

const word = WordMother.random({
id: TermIdMother.random(wordId),
id: TermIdMother.random(TERM_ID),
userId: UserIdMother.random(USER_ID_LOGGED),
}).toPrimitives();

Expand All @@ -62,18 +59,18 @@ describe('Update word feature', () => {
};

await request(app.getHttpServer())
.put(`/words/${wordId}`)
.put(`/words/${TERM_ID}`)
.set('Authorization', 'Bearer mock-token')
.send(wordData)
.expect(204);

const response = await request(app.getHttpServer())
.get(`/terms/${wordId}`)
.get(`/terms/${TERM_ID}`)
.set('Authorization', 'Bearer mock-token')
.expect(200);

expect(response.body).toEqual({
id: wordId,
id: TERM_ID,
countryId: wordData.countryId,
userId: USER_ID_LOGGED,
languageId: wordData.languageId,
Expand Down

0 comments on commit 8296023

Please sign in to comment.