@@ -27,19 +27,18 @@ describe('DeleteFiles Suite', function () {
27
27
fs . mkdirSync ( testRoot ) ;
28
28
} )
29
29
30
- function runValidations ( validator : ( ) => void , tr , done ) {
30
+ function runValidations ( validator : ( ) => void , tr : ttm . MockTestRunner ) {
31
31
try {
32
32
validator ( ) ;
33
- done ( ) ;
34
33
}
35
34
catch ( error ) {
36
35
console . log ( "STDERR" , tr . stderr ) ;
37
36
console . log ( "STDOUT" , tr . stdout ) ;
38
- done ( error ) ;
37
+ throw error ;
39
38
}
40
39
}
41
40
42
- it ( 'Deletes multiple nested folders' , ( done : Mocha . Done ) => {
41
+ it ( 'Deletes multiple nested folders' , async ( ) => {
43
42
this . timeout ( 5000 ) ;
44
43
45
44
const root = path . join ( testRoot , 'nested' ) ;
@@ -58,17 +57,17 @@ describe('DeleteFiles Suite', function () {
58
57
let tp : string = path . join ( __dirname , 'L0Nested.js' ) ;
59
58
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
60
59
61
- tr . run ( ) ;
60
+ await tr . runAsync ( ) ;
62
61
63
62
runValidations ( ( ) => {
64
63
assert ( ! fs . existsSync ( path . join ( root , 'A' ) ) ) ;
65
64
assert ( ! fs . existsSync ( path . join ( root , 'B' ) ) ) ;
66
65
assert ( fs . existsSync ( path . join ( root , 'C' ) ) ) ;
67
66
assert ( fs . existsSync ( path . join ( root , 'C' , 'dontDelete.txt' ) ) ) ;
68
- } , tr , done ) ;
67
+ } , tr ) ;
69
68
} ) ;
70
69
71
- it ( 'Deletes files with negate pattern' , ( done : Mocha . Done ) => {
70
+ it ( 'Deletes files with negate pattern' , async ( ) => {
72
71
this . timeout ( 5000 ) ;
73
72
74
73
const root = path . join ( testRoot , 'negate' ) ;
@@ -81,15 +80,15 @@ describe('DeleteFiles Suite', function () {
81
80
let tp : string = path . join ( __dirname , 'L0Negate.js' ) ;
82
81
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
83
82
84
- tr . run ( ) ;
83
+ await tr . runAsync ( ) ;
85
84
86
85
runValidations ( ( ) => {
87
86
assert ( ! fs . existsSync ( path . join ( root , 'A' , 'test2.css' ) ) ) ;
88
87
assert ( fs . existsSync ( path . join ( root , 'A' , 'test1.js' ) ) ) ;
89
- } , tr , done ) ;
88
+ } , tr ) ;
90
89
} ) ;
91
90
92
- it ( 'Deletes files starting with a dot' , ( done : Mocha . Done ) => {
91
+ it ( 'Deletes files starting with a dot' , async ( ) => {
93
92
const root = path . join ( testRoot , 'removeDotFiles' ) ;
94
93
fs . mkdirSync ( root ) ;
95
94
@@ -100,15 +99,15 @@ describe('DeleteFiles Suite', function () {
100
99
let tp : string = path . join ( __dirname , 'L0RemoveDotFiles.js' ) ;
101
100
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
102
101
103
- tr . run ( ) ;
102
+ await tr . runAsync ( ) ;
104
103
105
104
runValidations ( ( ) => {
106
105
assert ( ! fs . existsSync ( path . join ( root , 'A' , '.txt' ) ) ) ;
107
106
assert ( ! fs . existsSync ( path . join ( root , 'A' , '.sample.txt' ) ) ) ;
108
- } , tr , done ) ;
107
+ } , tr ) ;
109
108
} ) ;
110
109
111
- it ( 'Doesnt delete files starting with a dot' , ( done : Mocha . Done ) => {
110
+ it ( 'Doesnt delete files starting with a dot' , async ( ) => {
112
111
const root = path . join ( testRoot , 'DoesntRemoveDotFiles' ) ;
113
112
fs . mkdirSync ( root ) ;
114
113
@@ -119,15 +118,15 @@ describe('DeleteFiles Suite', function () {
119
118
let tp : string = path . join ( __dirname , 'L0DoesntRemoveDotFiles.js' ) ;
120
119
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
121
120
122
- tr . run ( ) ;
121
+ await tr . runAsync ( ) ;
123
122
124
123
runValidations ( ( ) => {
125
124
assert ( fs . existsSync ( path . join ( root , 'A' , '.txt' ) ) ) ;
126
125
assert ( fs . existsSync ( path . join ( root , 'A' , '.sample.txt' ) ) ) ;
127
- } , tr , done ) ;
126
+ } , tr ) ;
128
127
} ) ;
129
128
130
- it ( 'Deletes files using braces statement' , ( done : Mocha . Done ) => {
129
+ it ( 'Deletes files using braces statement' , async ( ) => {
131
130
this . timeout ( 5000 ) ;
132
131
133
132
const root = path . join ( testRoot , 'braces' ) ;
@@ -142,17 +141,17 @@ describe('DeleteFiles Suite', function () {
142
141
let tp : string = path . join ( __dirname , 'L0Braces.js' ) ;
143
142
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
144
143
145
- tr . run ( ) ;
144
+ await tr . runAsync ( ) ;
146
145
147
146
runValidations ( ( ) => {
148
147
assert ( ! fs . existsSync ( path . join ( root , 'A' , 'one.txt' ) ) ) ;
149
148
assert ( ! fs . existsSync ( path . join ( root , 'A' , 'two.txt' ) ) ) ;
150
149
assert ( fs . existsSync ( path . join ( root , 'A' , 'three.txt' ) ) ) ;
151
150
assert ( fs . existsSync ( path . join ( root , 'A' , 'four.txt' ) ) ) ;
152
- } , tr , done ) ;
151
+ } , tr ) ;
153
152
} ) ;
154
153
155
- it ( 'Deletes a single file' , ( done : Mocha . Done ) => {
154
+ it ( 'Deletes a single file' , async ( ) => {
156
155
this . timeout ( 5000 ) ;
157
156
158
157
const root = path . join ( testRoot , 'singleFile' ) ;
@@ -167,18 +166,18 @@ describe('DeleteFiles Suite', function () {
167
166
let tp : string = path . join ( __dirname , 'L0SingleFile.js' ) ;
168
167
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
169
168
170
- tr . run ( ) ;
169
+ await tr . runAsync ( ) ;
171
170
172
171
runValidations ( ( ) => {
173
172
assert ( fs . existsSync ( path . join ( root , 'A' ) ) ) ;
174
173
assert ( ! fs . existsSync ( path . join ( root , 'A' , 'test.txt' ) ) ) ;
175
174
assert ( fs . existsSync ( path . join ( root , 'A' , 'A' ) ) ) ;
176
175
assert ( fs . existsSync ( path . join ( root , 'A' , 'A' , 'test.txt' ) ) ) ;
177
176
assert ( fs . existsSync ( path . join ( root , 'A' , 'A' , 'test2.txt' ) ) ) ;
178
- } , tr , done ) ;
177
+ } , tr ) ;
179
178
} ) ;
180
179
181
- it ( 'Removes the source folder if its empty' , ( done : Mocha . Done ) => {
180
+ it ( 'Removes the source folder if its empty' , async ( ) => {
182
181
this . timeout ( 5000 ) ;
183
182
184
183
const root = path . join ( testRoot , 'rmSource' ) ;
@@ -193,14 +192,14 @@ describe('DeleteFiles Suite', function () {
193
192
let tp : string = path . join ( __dirname , 'L0RmSource.js' ) ;
194
193
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
195
194
196
- tr . run ( ) ;
195
+ await tr . runAsync ( ) ;
197
196
198
197
runValidations ( ( ) => {
199
198
assert ( ! fs . existsSync ( root ) ) ;
200
- } , tr , done ) ;
199
+ } , tr ) ;
201
200
} ) ;
202
201
203
- it ( 'Doesnt remove folder outside the root' , ( done : Mocha . Done ) => {
202
+ it ( 'Doesnt remove folder outside the root' , async ( ) => {
204
203
this . timeout ( 5000 ) ;
205
204
206
205
const root = path . join ( testRoot , 'insideRoot' ) ;
@@ -213,14 +212,14 @@ describe('DeleteFiles Suite', function () {
213
212
let tp : string = path . join ( __dirname , 'L0OutsideRoot.js' ) ;
214
213
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
215
214
216
- tr . run ( ) ;
215
+ await tr . runAsync ( ) ;
217
216
218
217
runValidations ( ( ) => {
219
218
assert ( fs . existsSync ( path . join ( outsideRoot , 'test.txt' ) ) ) ;
220
- } , tr , done ) ;
219
+ } , tr ) ;
221
220
} ) ;
222
221
223
- it ( 'Removes folder with locked file' , ( done : Mocha . Done ) => {
222
+ it ( 'Removes folder with locked file' , async ( ) => {
224
223
this . timeout ( 5000 ) ;
225
224
226
225
const root = path . join ( testRoot , 'locked' ) ;
@@ -233,7 +232,7 @@ describe('DeleteFiles Suite', function () {
233
232
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
234
233
235
234
try {
236
- tr . run ( ) ;
235
+ await tr . runAsync ( ) ;
237
236
}
238
237
catch ( err ) { }
239
238
finally {
@@ -243,6 +242,6 @@ describe('DeleteFiles Suite', function () {
243
242
runValidations ( ( ) => {
244
243
assert ( ! fs . existsSync ( path . join ( root , 'A' ) ) ) ;
245
244
assert ( tr . succeeded ) ;
246
- } , tr , done ) ;
245
+ } , tr ) ;
247
246
} ) ;
248
247
} ) ;
0 commit comments