mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
sample: migrate from removed jest matchers
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user