@@ -5,11 +5,16 @@ import * as fse from 'fs-extra'
55
66describe ( 'Resolver command test' , ( ) => {
77 let res : AbstractCommand
8- const pathToType = './test/commands/resolver/test-schema.ts'
9- const pathToActualResolver = './test/output/actual/test-resolver.ts'
8+ const pathToType1 = './test/commands/resolver/legal-schemas/test-schema1.ts'
9+ const pathToTypeTweets = './test/commands/resolver/legal-schemas/tweet-test-schema.ts'
10+ const pathToIllegalSchema1 = './test/commands/resolver/illegal-schemas/illegal-schema1.ts'
11+ const pathToActualResolver1 = './test/output/actual/test-resolver.ts'
12+ const pathToActualResolverTweets = './test/output/actual/tweets-test-resolver.ts'
1013 const pathToDirectoryActualResolver = './test/output/actual/non/existing/dir/test-resolver.ts'
1114 const resolverDirLocation = './test/output/actual/non'
12- const pathToExpectedResolver = './test/output/expected/commands/resolver/test-resolver.ts'
15+ const pathToExpectedResolver1 = './test/output/expected/commands/resolver/test-resolver.ts'
16+ const pathToExpectedResolverTweets =
17+ './test/output/expected/commands/resolver/tweets-test-resolver.ts'
1318 const pathToNonOverridenFile =
1419 './test/output/expected/commands/resolver/test-not-overriden-by-resolver.ts'
1520
@@ -18,8 +23,11 @@ describe('Resolver command test', () => {
1823 } )
1924
2025 afterEach ( ( ) => {
21- if ( fs . existsSync ( pathToActualResolver ) ) {
22- fs . unlinkSync ( pathToActualResolver )
26+ if ( fs . existsSync ( pathToActualResolver1 ) ) {
27+ fs . unlinkSync ( pathToActualResolver1 )
28+ }
29+ if ( fs . existsSync ( pathToActualResolverTweets ) ) {
30+ fs . unlinkSync ( pathToActualResolverTweets )
2331 }
2432 fs . stat ( resolverDirLocation , ( err , stats ) => {
2533 if ( ! err ) {
@@ -40,39 +48,67 @@ describe('Resolver command test', () => {
4048 expect ( act ) . toBeInstanceOf ( Function )
4149 } )
4250
43- it ( 'works if resolver file was generated' , async ( ) => {
51+ it ( 'works if resolver file was not generated for illegal schema 1 ' , async ( ) => {
4452 const actFunction = res . getAction ( )
45- await actFunction ( pathToType , pathToActualResolver )
46- const resolverFileExist : boolean = fs . existsSync ( pathToActualResolver )
53+ await actFunction ( pathToIllegalSchema1 , pathToActualResolver1 )
54+ const resolverFileExist : boolean = fs . existsSync ( pathToActualResolver1 )
55+ expect ( resolverFileExist ) . not . toBeTruthy ( )
56+ } )
57+
58+ it ( 'works if resolver file was generated for test-schema-1' , async ( ) => {
59+ const actFunction = res . getAction ( )
60+ await actFunction ( pathToType1 , pathToActualResolver1 )
61+ const resolverFileExist : boolean = fs . existsSync ( pathToActualResolver1 )
62+ expect ( resolverFileExist ) . toBeTruthy ( )
63+ } )
64+
65+ it ( 'works if resolver file was generated for tweet-test-schema' , async ( ) => {
66+ const actFunction = res . getAction ( )
67+ await actFunction ( pathToTypeTweets , pathToActualResolverTweets )
68+ const resolverFileExist : boolean = fs . existsSync ( pathToActualResolverTweets )
4769 expect ( resolverFileExist ) . toBeTruthy ( )
4870 } )
4971
5072 it ( 'works if resolver file was generated in directory structure' , async ( ) => {
5173 const actFunction = res . getAction ( )
52- await actFunction ( pathToType , pathToDirectoryActualResolver )
74+ await actFunction ( pathToType1 , pathToDirectoryActualResolver )
5375 const resolverFileExist : boolean = fs . existsSync ( pathToDirectoryActualResolver )
5476 expect ( resolverFileExist ) . toBeTruthy ( )
5577 } )
5678
57- it ( 'works if resolver file is identical to expected file' , async ( ) => {
79+ it ( 'works if resolver file is identical to expected file for test-schema1' , async ( ) => {
80+ const actFunction = res . getAction ( )
81+ await actFunction ( pathToType1 , pathToActualResolver1 )
82+ const expectedContent = fs
83+ . readFileSync ( pathToExpectedResolver1 )
84+ . toString ( )
85+ . replace ( / \s / g, '' )
86+ const actualContent = fs
87+ . readFileSync ( pathToActualResolver1 )
88+ . toString ( )
89+ . replace ( / \s / g, '' )
90+ expect ( actualContent ) . toEqual ( expectedContent )
91+ } )
92+
93+ it ( 'works if resolver file is identical to expected file for tweets-test-schema' , async ( ) => {
5894 const actFunction = res . getAction ( )
59- await actFunction ( pathToType , pathToActualResolver )
95+ await actFunction ( pathToTypeTweets , pathToActualResolverTweets )
6096 const expectedContent = fs
61- . readFileSync ( pathToExpectedResolver )
97+ . readFileSync ( pathToExpectedResolverTweets )
6298 . toString ( )
6399 . replace ( / \s / g, '' )
64100 const actualContent = fs
65- . readFileSync ( pathToActualResolver )
101+ . readFileSync ( pathToActualResolverTweets )
66102 . toString ( )
67103 . replace ( / \s / g, '' )
68104 expect ( actualContent ) . toEqual ( expectedContent )
69105 } )
70106
71107 it ( 'works if resolver command does not override existing file' , async ( ) => {
72108 const actFunction = res . getAction ( )
73- await actFunction ( pathToType , pathToNonOverridenFile )
109+ await actFunction ( pathToType1 , pathToNonOverridenFile )
74110 const expectedContent = fs
75- . readFileSync ( pathToExpectedResolver )
111+ . readFileSync ( pathToExpectedResolver1 )
76112 . toString ( )
77113 . replace ( / \s / g, '' )
78114 const actualContent = fs
0 commit comments