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

Code before:
              showName: false
            },
            isJsAlgoDataStructCert: true,
            completedChallenges: [
              {
                id: '561abd10cb81ac38a17513bc', // Cert ID
                completedDate: DATE_NOW
              }
            ]
          }
        });

        const response = await superRequest(
          '/certificate/showCert/foobar/javascript-algorithms-and-data-structures',
          {
            method: 'GET'
          }
        );

        expect(response.body).toEqual({
          certSlug: 'javascript-algorithms-and-data-structures',
          certTitle: 'Legacy JavaScript Algorithms and Data Structures',
          username: 'foobar',
          date: DATE_NOW,
          completionTime: 300
        });
        expect(response.status).toBe(200);
      });

      test('should return user full name if `showName` is `true`', async () => {
        await fastifyTestInstance.prisma.user.update({
          where: { id: defaultUserId },
          data: {
            profileUI: {
              showTimeLine: true,
              showCerts: true,
              isLocked: false,
              showName: true
            },
            isJsAlgoDataStructCert: true,
            completedChallenges: [
              {
                id: '561abd10cb81ac38a17513bc', // Cert ID
                completedDate: DATE_NOW
              }
            ]
          }
        });

        const response = await superRequest(
          '/certificate/showCert/foobar/javascript-algorithms-and-data-structures',

Review comment (suggestion):
```suggestion
        // TODO: delete this assertion once there's only one status 200 response
        expect(response.body).toHaveProperty('username', 'foobar');
        expect(response.body).not.toHaveProperty('name');
```
We don't really need to worry about the other properties. `name` is the one we're interested in.

Code after:
              showName: false
            },
            isJsAlgoDataStructCert: true,
            completedChallenges: [
              {
                id: '561abd10cb81ac38a17513bc', // Cert ID
                completedDate: DATE_NOW
              }
            ]
          }
        });

        const response = await superRequest(
          '/certificate/showCert/foobar/javascript-algorithms-and-data-structures',
          {
            method: 'GET'
          }
        );

        // TODO: delete this assertion once there's only one status 200 response
        expect(response.body).toHaveProperty('username', 'foobar');
        expect(response.body).not.toHaveProperty('name');
        expect(response.status).toBe(200);
      });

      test('should return user full name if `showName` is `true`', async () => {
        await fastifyTestInstance.prisma.user.update({
          where: { id: defaultUserId },
          data: {
            profileUI: {
              showTimeLine: true,
              showCerts: true,
              isLocked: false,
              showName: true
            },
            isJsAlgoDataStructCert: true,
            completedChallenges: [
              {
                id: '561abd10cb81ac38a17513bc', // Cert ID
                completedDate: DATE_NOW
              }
            ]
          }
        });

        const response = await superRequest(
          '/certificate/showCert/foobar/javascript-algorithms-and-data-structures',
          {
            method: 'GET'
          }
        );