Skip to content

Commit

Permalink
test(code-first): added tests for enum capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
kasvith committed Feb 10, 2022
1 parent 406113a commit c2f9576
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
5 changes: 0 additions & 5 deletions packages/apollo/tests/code-first/cats/cats.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<<<<<<< HEAD
import { Query, Resolver, Args } from '@nestjs/graphql';
=======
import { Args, Query, Resolver } from '@nestjs/graphql';
>>>>>>> 7624329 (chore(code-first): update imports to workspace paths)
import { CatType } from '../enums/cat-type.enum';

@Resolver()
Expand All @@ -12,7 +8,6 @@ export class CatsResolver {
return 'cat';
}

@Resolver()
@Query((returns) => CatType)
catType(
@Args({ name: 'catType', type: () => CatType })
Expand Down
5 changes: 2 additions & 3 deletions packages/apollo/tests/code-first/enums/cat-type.enum.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { registerEnumType } from '@nestjs/graphql';
<<<<<<< HEAD

=======
>>>>>>> 7624329 (chore(code-first): update imports to workspace paths)
export enum CatType {
PersianCat = 'persian-cat',
MaineCoon = 'maine-coon',
Ragdoll = 'ragdoll',
SomeNewAwesomeCat = 'some-new-awesome-cat',
SomeWEIRDCat = 'some-weird-cat',
}

registerEnumType(CatType, {
Expand Down
16 changes: 14 additions & 2 deletions packages/apollo/tests/e2e/code-first-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ describe('Code-first - schema factory', () => {
printedSchemaSnapshot,
);
});
it('should define 6 queries', async () => {
it('should define 7 queries', async () => {
const type = getQuery(introspectionSchema);

expect(type.fields.length).toEqual(6);
expect(type.fields.length).toEqual(7);
expect(type.fields.map((item) => item.name)).toEqual(
expect.arrayContaining([
'recipes',
Expand Down Expand Up @@ -186,6 +186,18 @@ describe('Code-first - schema factory', () => {
isDeprecated: false,
name: 'RAGDOLL',
},
{
deprecationReason: null,
description: null,
isDeprecated: false,
name: 'SOME_NEW_AWESOME_CAT',
},
{
deprecationReason: null,
description: null,
isDeprecated: false,
name: 'SOME_WEIRD_CAT',
},
],
}),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo/tests/graphql/sort-auto-schema.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CatsModule } from '../code-first/cats/cats.module';
imports: [
RecipesModule,
DirectionsModule,
CatsModule,
CatsModule.register('useClass'),
GraphQLModule.forRoot({
driver: ApolloDriver,
autoSchemaFile: 'schema.graphql',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CatsModule } from '../code-first/cats/cats.module';
imports: [
RecipesModule,
DirectionsModule,
CatsModule,
CatsModule.register('useClass'),
GraphQLModule.forRoot({
driver: ApolloDriver,
autoSchemaFile: 'schema.graphql',
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo/tests/utils/printed-schema.snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type Query {
take: Int = 25
): [Recipe!]!
move(direction: Direction!): Direction!
getAnimalName: String!
catType(catType: CatType!): CatType!
}
Expand All @@ -96,6 +97,8 @@ enum CatType {
PERSIAN_CAT
MAINE_COON
RAGDOLL
SOME_NEW_AWESOME_CAT
SOME_WEIRD_CAT
}
type Mutation {
Expand Down Expand Up @@ -126,6 +129,8 @@ enum CatType {
MAINE_COON
PERSIAN_CAT
RAGDOLL
SOME_NEW_AWESOME_CAT
SOME_WEIRD_CAT
}
type Category {
Expand Down Expand Up @@ -179,6 +184,7 @@ input NewRecipeInput {
type Query {
catType(catType: CatType!): CatType!
categories: [Category!]!
getAnimalName: String!
move(direction: Direction!): Direction!
"""get recipe by id"""
Expand Down

0 comments on commit c2f9576

Please sign in to comment.