sample: migrate from removed jest matchers

This commit is contained in:
Kamil Myśliwiec
2025-10-13 13:41:49 +02:00
parent 778eeb05a0
commit a1b75ff404
2 changed files with 6 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './user.entity';
import { UsersService } from './users.service';
import { Repository } from 'typeorm';
const userArray = [
{
@@ -76,7 +76,7 @@ describe('UserService', () => {
it('should get a single user', () => {
const repoSpy = jest.spyOn(repository, 'findOneBy');
expect(service.findOne(1)).resolves.toEqual(oneUser);
expect(repoSpy).toBeCalledWith({ id: 1 });
expect(repoSpy).toHaveBeenCalledWith({ id: 1 });
});
});
@@ -84,7 +84,7 @@ describe('UserService', () => {
it('should call remove with the passed value', async () => {
const removeSpy = jest.spyOn(repository, 'delete');
const retVal = await service.remove('2');
expect(removeSpy).toBeCalledWith('2');
expect(removeSpy).toHaveBeenCalledWith('2');
expect(retVal).toBeUndefined();
});
});

View File

@@ -1,7 +1,7 @@
import { getModelToken } from '@nestjs/sequelize';
import { Test, TestingModule } from '@nestjs/testing';
import { User } from './models/user.model';
import { UsersService } from './users.service';
import { getModelToken } from '@nestjs/sequelize';
const usersArray = [
{
@@ -74,7 +74,7 @@ describe('UserService', () => {
it('should get a single user', () => {
const findSpy = jest.spyOn(model, 'findOne');
expect(service.findOne('1'));
expect(findSpy).toBeCalledWith({ where: { id: '1' } });
expect(findSpy).toHaveBeenCalledWith({ where: { id: '1' } });
});
});
@@ -84,7 +84,7 @@ describe('UserService', () => {
destroy: jest.fn(),
} as any);
const retVal = await service.remove('2');
expect(findSpy).toBeCalledWith({ where: { id: '2' } });
expect(findSpy).toHaveBeenCalledWith({ where: { id: '2' } });
expect(retVal).toBeUndefined();
});
});