Repository: freeCodeCamp/freeCodeCamp
File: api/src/db/extensions.test.ts (TypeScript)

Code before:
      expect(user).toMatchObject({
        updateCount: 0
      });
    });

    it('should increment by one for updates and creates', async () => {
      const user = await fastifyTestInstance.prisma.user.create({
        data: createUserInput(defaultUserEmail)
      });

      const updateUser = await fastifyTestInstance.prisma.user.update({
        where: { id: user.id },
        data: { username: 'any-change' }
      });

      expect(updateUser).toMatchObject({
        username: 'any-change',
        updateCount: 1
      });

      const _updateManyResult =
        await fastifyTestInstance.prisma.user.updateMany({
          where: { id: user.id },
          // Even no change to values updates the updateCount
          data: { username: 'any-change' }
        });

      const updateManyUser = await fastifyTestInstance.prisma.user.findUnique({
        where: { id: user.id }
      });

      expect(updateManyUser).toMatchObject({
        username: 'any-change',
        updateCount: 2
      });

      const upsertUser = await fastifyTestInstance.prisma.user.upsert({
        where: { id: user.id },
        create: createUserInput(defaultUserEmail),
        update: { username: 'upser-user' }
      });

      expect(upsertUser).toMatchObject({
        username: 'upser-user',
        updateCount: 3
      });
    });

    it("should not increment for 'find' queries", async () => {
      const user = await fastifyTestInstance.prisma.user.create({
        data: createUserInput(defaultUserEmail)

Review comment (suggestion):
```suggestion
      await fastifyTestInstance.prisma.user.updateMany({
        where: { id: user.id },
        // Even no change to values updates the updateCount
        data: { username: 'any-change' }
      });
```
Nit: we're only interested in the side-effects.

Code after:
      expect(user).toMatchObject({
        updateCount: 0
      });
    });

    it('should increment by one for updates and creates', async () => {
      const user = await fastifyTestInstance.prisma.user.create({
        data: createUserInput(defaultUserEmail)
      });

      const updateUser = await fastifyTestInstance.prisma.user.update({
        where: { id: user.id },
        data: { username: 'any-change' }
      });

      expect(updateUser).toMatchObject({
        username: 'any-change',
        updateCount: 1
      });

      await fastifyTestInstance.prisma.user.updateMany({
        where: { id: user.id },
        // Even no change to values updates the updateCount
        data: { username: 'any-change' }
      });

      const updateManyUser = await fastifyTestInstance.prisma.user.findUnique({
        where: { id: user.id }
      });

      expect(updateManyUser).toMatchObject({
        username: 'any-change',
        updateCount: 2
      });

      const upsertUser = await fastifyTestInstance.prisma.user.upsert({
        where: { id: user.id },
        create: createUserInput(defaultUserEmail),
        update: { username: 'upser-user' }
      });

      expect(upsertUser).toMatchObject({
        username: 'upser-user',
        updateCount: 3
      });
    });

    it("should not increment for 'find' queries", async () => {
      const user = await fastifyTestInstance.prisma.user.create({
        data: createUserInput(defaultUserEmail)
      });