1
1
const { getCodegenConfig } = require ( '../../src/codegen-config' ) ;
2
2
const fs = require ( 'fs-extra' ) ;
3
3
const graphQLConfig = require ( 'graphql-config' ) ;
4
+ const path = require ( 'path' ) ;
4
5
5
6
jest . mock ( 'fs-extra' ) ;
6
7
jest . mock ( 'graphql-config' ) ;
@@ -50,10 +51,10 @@ describe('get codegen configuration', () => {
50
51
fs . existsSync = jest . fn ( ) . mockReturnValue ( true ) ;
51
52
graphQLConfig . getGraphQLConfig = jest . fn ( ) . mockReturnValue ( MOCK_CODEGEN_CONFIG ) ;
52
53
const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
53
- expect ( getConfigReturn . getGeneratedQueriesPath ( ) ) . toEqual ( 'src/ graphql/ queries' ) ;
54
- expect ( getConfigReturn . getGeneratedMutationsPath ( ) ) . toEqual ( 'src/ graphql/ mutations' ) ;
55
- expect ( getConfigReturn . getGeneratedSubscriptionsPath ( ) ) . toEqual ( 'src/ graphql/ subscriptions' ) ;
56
- expect ( getConfigReturn . getGeneratedFragmentsPath ( ) ) . toEqual ( 'src/ graphql/ fragments' ) ;
54
+ expect ( getConfigReturn . getGeneratedQueriesPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' queries') ) ;
55
+ expect ( getConfigReturn . getGeneratedMutationsPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' mutations') ) ;
56
+ expect ( getConfigReturn . getGeneratedSubscriptionsPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' subscriptions') ) ;
57
+ expect ( getConfigReturn . getGeneratedFragmentsPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' fragments') ) ;
57
58
} ) ;
58
59
59
60
it ( 'uses the includes property if the generated documents path does not exist' , ( ) => {
@@ -62,17 +63,17 @@ describe('get codegen configuration', () => {
62
63
fs . existsSync = jest . fn ( ) . mockReturnValue ( true ) ;
63
64
graphQLConfig . getGraphQLConfig = jest . fn ( ) . mockReturnValue ( configWithoutDocumentsPath ) ;
64
65
const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
65
- expect ( getConfigReturn . getGeneratedQueriesPath ( ) ) . toEqual ( 'src/ graphql/ queries' ) ;
66
- expect ( getConfigReturn . getGeneratedMutationsPath ( ) ) . toEqual ( 'src/ graphql/ mutations' ) ;
67
- expect ( getConfigReturn . getGeneratedSubscriptionsPath ( ) ) . toEqual ( 'src/ graphql/ subscriptions' ) ;
68
- expect ( getConfigReturn . getGeneratedFragmentsPath ( ) ) . toEqual ( 'src/ graphql/ fragments' ) ;
66
+ expect ( getConfigReturn . getGeneratedQueriesPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' queries') ) ;
67
+ expect ( getConfigReturn . getGeneratedMutationsPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' mutations') ) ;
68
+ expect ( getConfigReturn . getGeneratedSubscriptionsPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' subscriptions') ) ;
69
+ expect ( getConfigReturn . getGeneratedFragmentsPath ( ) ) . toEqual ( path . join ( 'src' , ' graphql' , ' fragments') ) ;
69
70
} ) ;
70
71
71
72
it ( 'correctly returns the generated types path if exists' , ( ) => {
72
73
fs . existsSync = jest . fn ( ) . mockReturnValue ( true ) ;
73
74
graphQLConfig . getGraphQLConfig = jest . fn ( ) . mockReturnValue ( MOCK_CODEGEN_CONFIG ) ;
74
75
const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
75
- expect ( getConfigReturn . getGeneratedTypesPath ( ) ) . toEqual ( 'src/ API.ts' ) ;
76
+ expect ( getConfigReturn . getGeneratedTypesPath ( ) ) . toEqual ( path . join ( 'src' , ' API.ts') ) ;
76
77
} ) ;
77
78
78
79
it ( 'returns undefined if types path does not exist' , ( ) => {
0 commit comments