@@ -9,6 +9,7 @@ import { GetManyInput, GetOneInput } from 'src/common/graphql/custom.input'
99import { {{ pascalCase tableName }} } from './entities/{{ tableName }} .entity'
1010import { UtilModule } from 'src/common/shared/services/util.module';
1111import { UtilService } from 'src/common/shared/services/util.service';
12+ import { DataSource } from 'typeorm';
1213
1314import { Create{{ pascalCase tableName }} Input, Update{{ pascalCase tableName }} Input } from './inputs/{{ tableName }} .input'
1415
@@ -26,6 +27,10 @@ describe('{{pascalCase tableName}}Resolver', () => {
2627 provide: {{ pascalCase tableName }} Service,
2728 useFactory: MockServiceFactory.getMockService({{ pascalCase tableName }} Service),
2829 },
30+ {
31+ provide: DataSource,
32+ useValue: undefined,
33+ },
2934 ],
3035 }).compile()
3136
@@ -39,7 +44,7 @@ describe('{{pascalCase tableName}}Resolver', () => {
3944 })
4045
4146 it('Calling "Get many {{ tableName }} list" method', () => {
42- const qs : GetManyInput<{{pascalCase tableName}}> = {
47+ const condition : GetManyInput<{{pascalCase tableName}}> = {
4348 where: {
4449 {{ #if (is " increment" idType )}}
4550 id: utilService.getRandomNumber(0,999999)
@@ -49,22 +54,17 @@ describe('{{pascalCase tableName}}Resolver', () => {
4954 },
5055 }
5156
52- const gqlQuery = `
53- query GetMany{{ pascalCase tableName }} List {
54- getMany{{ pascalCase tableName }} List {
55- data {
56- id
57- }
58- }
59- }
60- `
61-
62- expect(resolver.getMany{{ pascalCase tableName }} List(qs, gqlQuery)).not.toEqual(null)
63- expect(mockedService.getMany).toHaveBeenCalledWith(qs, gqlQuery)
57+ const option = { relations: undefined, select: undefined };
58+
59+ expect(resolver.getMany{{ pascalCase tableName }} List(condition, option)).not.toEqual(null)
60+ expect(mockedService.getMany).toHaveBeenCalledWith({
61+ ...condition,
62+ ...option,
63+ })
6464 })
6565
6666 it('Calling "Get one {{ tableName }} list" method', () => {
67- const qs : GetOneInput<{{pascalCase tableName}}> = {
67+ const condition : GetOneInput<{{pascalCase tableName}}> = {
6868 where: {
6969{{ #if (is " increment" idType )}}
7070 id: utilService.getRandomNumber(0,999999)
@@ -74,18 +74,13 @@ describe('{{pascalCase tableName}}Resolver', () => {
7474 },
7575 }
7676
77- const gqlQuery = `
78- query GetOne{{ pascalCase tableName }} {
79- getOne{{ pascalCase tableName }} {
80- data {
81- id
82- }
83- }
84- }
85- `
86-
87- expect(resolver.getOne{{ pascalCase tableName }} (qs, gqlQuery)).not.toEqual(null)
88- expect(mockedService.getOne).toHaveBeenCalledWith(qs, gqlQuery)
77+ const option = { relations: undefined, select: undefined };
78+
79+ expect(resolver.getOne{{ pascalCase tableName }} (condition, option)).not.toEqual(null)
80+ expect(mockedService.getOne).toHaveBeenCalledWith({
81+ ...condition,
82+ ...option,
83+ })
8984 })
9085
9186 it('Calling "Create {{ tableName }} " method', () => {
0 commit comments