forked from nestjs/graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphql-sort-schema.spec.ts
More file actions
60 lines (49 loc) · 1.38 KB
/
graphql-sort-schema.spec.ts
File metadata and controls
60 lines (49 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { GraphQLSchema } from 'graphql';
import { printSchema } from '@apollo/federation';
import { SortSchemaModule } from '../graphql/sort-schema.module';
import { GRAPHQL_SDL_FILE_HEADER } from '../../lib/graphql.constants';
import { GraphQLSchemaHost } from '../../lib';
describe('GraphQL sort schema', () => {
let app: INestApplication;
let schema: GraphQLSchema;
beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [SortSchemaModule],
}).compile();
app = module.createNestApplication();
await app.init();
const graphQLSchemaHost = app.get<GraphQLSchemaHost>(GraphQLSchemaHost);
schema = graphQLSchemaHost.schema;
});
it('should match schema snapshot', () => {
expect(GRAPHQL_SDL_FILE_HEADER + printSchema(schema)).toEqual(
expectedSchema,
);
});
afterEach(async () => {
await app.close();
});
});
const expectedSchema = `# ------------------------------------------------------
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------
type Cat {
age: Int
color: String
id: Int
name: String
weight: Int
}
type Mutation {
createCat(name: String): Cat
}
type Query {
cat(id: ID!): Cat
getCats: [Cat]
}
type Subscription {
catCreated: Cat
}
`;