@@ -5,12 +5,16 @@ import * as fse from 'fs-extra'
55
66describe ( 'Resolver command test' , ( ) => {
77 let res : AbstractCommand
8- const pathToType = './test/commands/resolver/legal-schemas/test-schema1.ts'
8+ const pathToType1 = './test/commands/resolver/legal-schemas/test-schema1.ts'
9+ const pathToTypeTweets = './test/commands/resolver/legal-schemas/tweet-test-schema.ts'
910 const pathToIllegalSchema1 = './test/commands/resolver/illegal-schemas/illegal-schema1.ts'
10- const pathToActualResolver = './test/output/actual/test-resolver.ts'
11+ const pathToActualResolver1 = './test/output/actual/test-resolver.ts'
12+ const pathToActualResolverTweets = './test/output/actual/tweets-test-resolver.ts'
1113 const pathToDirectoryActualResolver = './test/output/actual/non/existing/dir/test-resolver.ts'
1214 const resolverDirLocation = './test/output/actual/non'
13- 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'
1418 const pathToNonOverridenFile =
1519 './test/output/expected/commands/resolver/test-not-overriden-by-resolver.ts'
1620
@@ -19,8 +23,11 @@ describe('Resolver command test', () => {
1923 } )
2024
2125 afterEach ( ( ) => {
22- if ( fs . existsSync ( pathToActualResolver ) ) {
23- fs . unlinkSync ( pathToActualResolver )
26+ if ( fs . existsSync ( pathToActualResolver1 ) ) {
27+ fs . unlinkSync ( pathToActualResolver1 )
28+ }
29+ if ( fs . existsSync ( pathToActualResolverTweets ) ) {
30+ fs . unlinkSync ( pathToActualResolverTweets )
2431 }
2532 fs . stat ( resolverDirLocation , ( err , stats ) => {
2633 if ( ! err ) {
@@ -43,44 +50,65 @@ describe('Resolver command test', () => {
4350
4451 it ( 'works if resolver file was not generated for illegal schema 1' , async ( ) => {
4552 const actFunction = res . getAction ( )
46- await actFunction ( pathToIllegalSchema1 , pathToActualResolver )
47- const resolverFileExist : boolean = fs . existsSync ( pathToActualResolver )
53+ await actFunction ( pathToIllegalSchema1 , pathToActualResolver1 )
54+ const resolverFileExist : boolean = fs . existsSync ( pathToActualResolver1 )
4855 expect ( resolverFileExist ) . not . toBeTruthy ( )
4956 } )
5057
51- it ( 'works if resolver file was generated' , async ( ) => {
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 ( ) => {
5266 const actFunction = res . getAction ( )
53- await actFunction ( pathToType , pathToActualResolver )
54- const resolverFileExist : boolean = fs . existsSync ( pathToActualResolver )
67+ await actFunction ( pathToTypeTweets , pathToActualResolverTweets )
68+ const resolverFileExist : boolean = fs . existsSync ( pathToActualResolverTweets )
5569 expect ( resolverFileExist ) . toBeTruthy ( )
5670 } )
5771
5872 it ( 'works if resolver file was generated in directory structure' , async ( ) => {
5973 const actFunction = res . getAction ( )
60- await actFunction ( pathToType , pathToDirectoryActualResolver )
74+ await actFunction ( pathToType1 , pathToDirectoryActualResolver )
6175 const resolverFileExist : boolean = fs . existsSync ( pathToDirectoryActualResolver )
6276 expect ( resolverFileExist ) . toBeTruthy ( )
6377 } )
6478
65- it . only ( '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 ( ) => {
6694 const actFunction = res . getAction ( )
67- await actFunction ( pathToType , pathToActualResolver )
95+ await actFunction ( pathToTypeTweets , pathToActualResolverTweets )
6896 const expectedContent = fs
69- . readFileSync ( pathToExpectedResolver )
97+ . readFileSync ( pathToExpectedResolverTweets )
7098 . toString ( )
7199 . replace ( / \s / g, '' )
72100 const actualContent = fs
73- . readFileSync ( pathToActualResolver )
101+ . readFileSync ( pathToActualResolverTweets )
74102 . toString ( )
75103 . replace ( / \s / g, '' )
76104 expect ( actualContent ) . toEqual ( expectedContent )
77105 } )
78106
79107 it ( 'works if resolver command does not override existing file' , async ( ) => {
80108 const actFunction = res . getAction ( )
81- await actFunction ( pathToType , pathToNonOverridenFile )
109+ await actFunction ( pathToType1 , pathToNonOverridenFile )
82110 const expectedContent = fs
83- . readFileSync ( pathToExpectedResolver )
111+ . readFileSync ( pathToExpectedResolver1 )
84112 . toString ( )
85113 . replace ( / \s / g, '' )
86114 const actualContent = fs
0 commit comments