Skip to content

Commit c2f9576

Browse files
committed
test(code-first): added tests for enum capitalization
1 parent 406113a commit c2f9576

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

packages/apollo/tests/code-first/cats/cats.resolver.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<<<<<<< HEAD
2-
import { Query, Resolver, Args } from '@nestjs/graphql';
3-
=======
41
import { Args, Query, Resolver } from '@nestjs/graphql';
5-
>>>>>>> 7624329 (chore(code-first): update imports to workspace paths)
62
import { CatType } from '../enums/cat-type.enum';
73

84
@Resolver()
@@ -12,7 +8,6 @@ export class CatsResolver {
128
return 'cat';
139
}
1410

15-
@Resolver()
1611
@Query((returns) => CatType)
1712
catType(
1813
@Args({ name: 'catType', type: () => CatType })

packages/apollo/tests/code-first/enums/cat-type.enum.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { registerEnumType } from '@nestjs/graphql';
2-
<<<<<<< HEAD
32

4-
=======
5-
>>>>>>> 7624329 (chore(code-first): update imports to workspace paths)
63
export enum CatType {
74
PersianCat = 'persian-cat',
85
MaineCoon = 'maine-coon',
96
Ragdoll = 'ragdoll',
7+
SomeNewAwesomeCat = 'some-new-awesome-cat',
8+
SomeWEIRDCat = 'some-weird-cat',
109
}
1110

1211
registerEnumType(CatType, {

packages/apollo/tests/e2e/code-first-schema.spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ describe('Code-first - schema factory', () => {
7070
printedSchemaSnapshot,
7171
);
7272
});
73-
it('should define 6 queries', async () => {
73+
it('should define 7 queries', async () => {
7474
const type = getQuery(introspectionSchema);
7575

76-
expect(type.fields.length).toEqual(6);
76+
expect(type.fields.length).toEqual(7);
7777
expect(type.fields.map((item) => item.name)).toEqual(
7878
expect.arrayContaining([
7979
'recipes',
@@ -186,6 +186,18 @@ describe('Code-first - schema factory', () => {
186186
isDeprecated: false,
187187
name: 'RAGDOLL',
188188
},
189+
{
190+
deprecationReason: null,
191+
description: null,
192+
isDeprecated: false,
193+
name: 'SOME_NEW_AWESOME_CAT',
194+
},
195+
{
196+
deprecationReason: null,
197+
description: null,
198+
isDeprecated: false,
199+
name: 'SOME_WEIRD_CAT',
200+
},
189201
],
190202
}),
191203
);

packages/apollo/tests/graphql/sort-auto-schema.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CatsModule } from '../code-first/cats/cats.module';
99
imports: [
1010
RecipesModule,
1111
DirectionsModule,
12-
CatsModule,
12+
CatsModule.register('useClass'),
1313
GraphQLModule.forRoot({
1414
driver: ApolloDriver,
1515
autoSchemaFile: 'schema.graphql',

packages/apollo/tests/graphql/transform-auto-schema-file.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CatsModule } from '../code-first/cats/cats.module';
1010
imports: [
1111
RecipesModule,
1212
DirectionsModule,
13-
CatsModule,
13+
CatsModule.register('useClass'),
1414
GraphQLModule.forRoot({
1515
driver: ApolloDriver,
1616
autoSchemaFile: 'schema.graphql',

packages/apollo/tests/utils/printed-schema.snapshot.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type Query {
7575
take: Int = 25
7676
): [Recipe!]!
7777
move(direction: Direction!): Direction!
78+
getAnimalName: String!
7879
catType(catType: CatType!): CatType!
7980
}
8081
@@ -96,6 +97,8 @@ enum CatType {
9697
PERSIAN_CAT
9798
MAINE_COON
9899
RAGDOLL
100+
SOME_NEW_AWESOME_CAT
101+
SOME_WEIRD_CAT
99102
}
100103
101104
type Mutation {
@@ -126,6 +129,8 @@ enum CatType {
126129
MAINE_COON
127130
PERSIAN_CAT
128131
RAGDOLL
132+
SOME_NEW_AWESOME_CAT
133+
SOME_WEIRD_CAT
129134
}
130135
131136
type Category {
@@ -179,6 +184,7 @@ input NewRecipeInput {
179184
type Query {
180185
catType(catType: CatType!): CatType!
181186
categories: [Category!]!
187+
getAnimalName: String!
182188
move(direction: Direction!): Direction!
183189
184190
"""get recipe by id"""

0 commit comments

Comments
 (0)