|
1 | 1 | import * as path from 'path' |
2 | 2 | import Executables from '../executables' |
3 | 3 |
|
4 | | -const executablesPromise = Executables.fromPath( |
5 | | - path.resolve(__dirname, '..', '..', '..', 'testing', 'executables'), |
6 | | -) |
| 4 | +let executables: Executables = null |
| 5 | + |
| 6 | +beforeAll(async () => { |
| 7 | + executables = await Executables.fromPath( |
| 8 | + path.resolve(__dirname, '..', '..', '..', 'testing', 'executables'), |
| 9 | + ) |
| 10 | +}) |
7 | 11 |
|
8 | 12 | describe('list', () => { |
9 | 13 | it('finds executables on the PATH', async () => { |
10 | | - expect.assertions(1) |
11 | | - const executables = await executablesPromise |
12 | 14 | const result = executables.list().find(x => x === 'iam-executable') |
13 | | - return expect(result).toBeTruthy() |
| 15 | + expect(result).toBeTruthy() |
14 | 16 | }) |
15 | 17 |
|
16 | 18 | it.skip('only considers files that have the executable bit set', async () => { |
17 | | - expect.assertions(1) |
18 | | - const executables = await executablesPromise |
19 | 19 | const result = executables.list().find(x => x === 'iam-not-executable') |
20 | | - return expect(result).toBeFalsy() |
| 20 | + expect(result).toBeFalsy() |
21 | 21 | }) |
22 | 22 |
|
23 | 23 | it('only considers executable directly on the PATH', async () => { |
24 | | - expect.assertions(1) |
25 | | - const executables = await executablesPromise |
26 | 24 | const result = executables.list().find(x => x === 'iam-executable-in-sub-folder') |
27 | | - return expect(result).toBeFalsy() |
| 25 | + expect(result).toBeFalsy() |
28 | 26 | }) |
29 | 27 | }) |
30 | 28 |
|
31 | 29 | describe('documentation', () => { |
32 | 30 | it('uses `man` so it disregards the PATH it has been initialized with', async () => { |
33 | | - expect.assertions(1) |
34 | | - const executables = await executablesPromise |
35 | 31 | const result = await executables.documentation('ls') |
36 | | - return expect(result).toBeTruthy() |
| 32 | + expect(result).toBeTruthy() |
37 | 33 | }) |
38 | 34 | }) |
39 | 35 |
|
40 | 36 | describe('isExecutableOnPATH', () => { |
41 | 37 | it('looks at the PATH it has been initialized with', async () => { |
42 | | - expect.assertions(1) |
43 | | - const executables = await executablesPromise |
44 | 38 | const result = executables.isExecutableOnPATH('ls') |
45 | | - return expect(result).toEqual(false) |
| 39 | + expect(result).toEqual(false) |
46 | 40 | }) |
47 | 41 | }) |
0 commit comments