File tree 1 file changed +29
-0
lines changed
core/aws-lsp-core/src/util
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import * as fs from 'fs'
2
+ import * as assert from 'assert'
3
+ import * as cp from 'child_process'
4
+
5
+ describe ( 'demo' , function ( ) {
6
+ const temporaryDir = '/tmp/myTestDirectory'
7
+
8
+ it ( 'test' , async function ( ) {
9
+ // Create temporary dir and assert it exists.
10
+ fs . mkdirSync ( temporaryDir , { recursive : true } )
11
+ assert . ok ( fs . existsSync ( temporaryDir ) , 'does not exist directly after creating' )
12
+
13
+ // Run a process that checks that it exists.
14
+ const result = new Promise ( ( resolve , reject ) => {
15
+ const proc = cp . spawn ( 'ls' , [ temporaryDir ] )
16
+ proc . on ( 'exit' , function ( code ) {
17
+ resolve ( code )
18
+ } )
19
+ proc . stderr . on ( 'data' , function ( data ) {
20
+ reject ( data . toString ( ) )
21
+ } )
22
+ } )
23
+ const r = await result
24
+ // Assert that process found the file
25
+ assert . strictEqual ( r , 0 , 'did not exit with 0' )
26
+ assert . ok ( fs . existsSync ( temporaryDir ) , 'does not exist after the test' )
27
+ fs . rmdirSync ( temporaryDir , { recursive : true } )
28
+ } )
29
+ } )
You can’t perform that action at this time.
0 commit comments