Repository: freeCodeCamp/freeCodeCamp
File: api/src/routes/challenge.test.ts (TypeScript)

Code before:
              }
            ]
          });
          expect(resUpdate.statusCode).toBe(200);
        });
      });
    });

    describe('/save-challenge', () => {
      describe('validation', () => {
        test('POST returns 403 status for unsavable challenges', async () => {
          const response = await superRequest('/save-challenge', {
            method: 'POST',
            setCookies
          }).send({
            savedChallenges: {
              id: 'not a valid id',
              lastSavedDate: Date.now(),
              files: multiFileCertProjectBody.files
            }
          });

          expect(response.body).toEqual({
            message: 'That challenge type is not savable.',
            type: 'error'
          });
          expect(response.statusCode).toBe(403);
        });
      });

      describe('handling', () => {
        afterEach(async () => {
          await fastifyTestInstance.prisma.user.updateMany({
            where: { email: 'foo@bar.com' },
            data: {
              savedChallenges: []
            }
          });
        });

        test('POST update the user savedchallenges and return them', async () => {
          const now = Date.now();
          const response = await superRequest('/save-challenge', {
            method: 'POST',
            setCookies
          }).send({
            id: multiFileCertProjectId,
            lastSavedDate: now,
            files: updatedMultiFileCertProjectBody.files
          });


Review comment (suggestion):
```suggestion
          expect(response.body).toEqual('That challenge type is not savable');
```
It's daft, but it's just a string response.

Code after:
              }
            ]
          });
          expect(resUpdate.statusCode).toBe(200);
        });
      });
    });

    describe('/save-challenge', () => {
      describe('validation', () => {
        test('POST returns 403 status for unsavable challenges', async () => {
          const response = await superRequest('/save-challenge', {
            method: 'POST',
            setCookies
          }).send({
            savedChallenges: {
              // valid mongo id, but not a savable one
              id: 'aaaaaaaaaaaaaaaaaaaaaaa',
              files: multiFileCertProjectBody.files
            }
          });

          expect(response.body).toEqual({
            message: 'That does not appear to be a valid challenge submission.',
            type: 'error'
          });
          expect(response.statusCode).toBe(400);
        });
      });

      describe('handling', () => {
        afterEach(async () => {
          await fastifyTestInstance.prisma.user.updateMany({
            where: { email: 'foo@bar.com' },
            data: {
              savedChallenges: []
            }
          });
        });

        test('POST update the user savedchallenges and return them', async () => {
          const response = await superRequest('/save-challenge', {
            method: 'POST',
            setCookies
          }).send({
            id: multiFileCertProjectId,
            files: updatedMultiFileCertProjectBody.files
          });

          const user = await fastifyTestInstance.prisma.user.findFirstOrThrow({
            where: { email: 'foo@bar.com' }