Skip to content

Commit

Permalink
fix(ci): Restore pizes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Oct 5, 2023
1 parent 3c941cf commit c0910a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

To run the full app in a Docker container :

`docker-compose up --build`
`docker compose up --build`

To stop the docker container :

`docker-compose down`
`docker compose down`

To run the app being sure that everythiing else is down :

`docker-compose down && docker system prune -f && docker-compose up --build`
`docker compose down && docker system prune -f && docker compose up --build`

This run a docker container, with a MongoDB inside and the paysage-api app.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ describe('API > prizes > create', () => {
.set('Authorization', authorization)
.send(payload)
.expect(201);
Object.entries(payload).map((entry) => expect(body[entry[0]]).toBe(entry[1]));
expect(body.nameFr).toBe(payload.nameFr);
expect(body.nameEn).toBe(payload.nameEn);
expect(body.id).toBeTruthy();
expect(body.createdBy.lastName).toBe('user');
id = body.id;
});

it('ignore additionalProperties', async () => {
const { body } = await global.superapp
.post(`/${resource}`)
Expand Down Expand Up @@ -53,23 +55,27 @@ describe('API > prizes > update', () => {
.send(updatePayLoad)
.expect(404);
});

it('can update successfully', async () => {
const { body } = await global.superapp
.patch(`/${resource}/${id}`)
.set('Authorization', authorization)
.send(updatePayLoad);
const updated = { ...payload, ...updatePayLoad };
Object.entries(updated).map((entry) => expect(body[entry[0]]).toBe(entry[1]));
expect(body.nameFr).toBe(updated.nameFr);
expect(body.nameEn).toBe(updated.nameEn);
expect(body.id).toBeTruthy();
expect(body.createdBy.lastName).toBe('user');
});

it('throws with wrong data', async () => {
await global.superapp
.patch(`/${resource}/${id}`)
.set('Authorization', authorization)
.send({ arbitrary: 'test' })
.expect(400);
});

it('throws with no data', async () => {
await global.superapp
.patch(`/${resource}/${id}`)
Expand All @@ -86,10 +92,12 @@ describe('API > prizes > read', () => {
.set('Authorization', authorization)
.expect(200);
const expected = { ...payload, ...updatePayLoad };
Object.entries(expected).map((entry) => expect(body[entry[0]]).toBe(entry[1]));
expect(body.nameFr).toBe(expected.nameFr);
expect(body.nameEn).toBe(expected.nameEn);
expect(body.id).toBe(id);
expect(body.createdBy.lastName).toBe('user');
});

it('throws not found with unknown id', async () => {
await global.superapp
.get(`/${resource}/45frK`)
Expand Down

0 comments on commit c0910a3

Please sign in to comment.