1
1
import { AbstractCommand } from '../../../src/commands/abstract-command'
2
2
import { Resolver } from '../../../src/commands/resolver/resolver'
3
3
import * as fs from 'fs'
4
+ import * as fse from 'fs-extra'
4
5
5
6
describe ( 'Resolver command test' , ( ) => {
6
7
let res : AbstractCommand
7
8
const pathToType = './test/commands/resolver/test-schema.ts'
8
9
const pathToActualResolver = './test/output/actual/test-resolver.ts'
10
+ const pathToDirectoryActualResolver = './test/output/actual/non/existing/dir/test-resolver.ts'
11
+ const resolverDirLocation = './test/output/actual/non'
9
12
const pathToExpectedResolver = './test/output/expected/commands/resolver/test-resolver.ts'
10
13
const pathToNonOverridenFile =
11
14
'./test/output/expected/commands/resolver/test-not-overriden-by-resolver.ts'
@@ -18,6 +21,18 @@ describe('Resolver command test', () => {
18
21
if ( fs . existsSync ( pathToActualResolver ) ) {
19
22
fs . unlinkSync ( pathToActualResolver )
20
23
}
24
+ fs . stat ( resolverDirLocation , ( err , stats ) => {
25
+ if ( ! err ) {
26
+ if ( stats . isDirectory ( ) ) {
27
+ fse . remove ( resolverDirLocation , err => {
28
+ console . log (
29
+ 'Could not remove resolver dir. On windows desktops, remove it manually...' ,
30
+ err
31
+ )
32
+ } )
33
+ }
34
+ }
35
+ } )
21
36
} )
22
37
23
38
it ( 'works if action returns a function' , ( ) => {
@@ -32,6 +47,13 @@ describe('Resolver command test', () => {
32
47
expect ( resolverFileExist ) . toBeTruthy ( )
33
48
} )
34
49
50
+ it ( 'works if resolver file was generated in directory structure' , async ( ) => {
51
+ const actFunction = res . getAction ( )
52
+ await actFunction ( pathToType , pathToDirectoryActualResolver )
53
+ const resolverFileExist : boolean = fs . existsSync ( pathToDirectoryActualResolver )
54
+ expect ( resolverFileExist ) . toBeTruthy ( )
55
+ } )
56
+
35
57
it ( 'works if resolver file is identical to expected file' , async ( ) => {
36
58
const actFunction = res . getAction ( )
37
59
await actFunction ( pathToType , pathToActualResolver )
0 commit comments