Skip to content

Commit d9e602d

Browse files
Merge pull request #34 from mads-hartmann/simpler-executables-test
Simplify executables unit test
2 parents e9f2ea0 + f375e1f commit d9e602d

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,41 @@
11
import * as path from 'path'
22
import Executables from '../executables'
33

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+
})
711

812
describe('list', () => {
913
it('finds executables on the PATH', async () => {
10-
expect.assertions(1)
11-
const executables = await executablesPromise
1214
const result = executables.list().find(x => x === 'iam-executable')
13-
return expect(result).toBeTruthy()
15+
expect(result).toBeTruthy()
1416
})
1517

1618
it.skip('only considers files that have the executable bit set', async () => {
17-
expect.assertions(1)
18-
const executables = await executablesPromise
1919
const result = executables.list().find(x => x === 'iam-not-executable')
20-
return expect(result).toBeFalsy()
20+
expect(result).toBeFalsy()
2121
})
2222

2323
it('only considers executable directly on the PATH', async () => {
24-
expect.assertions(1)
25-
const executables = await executablesPromise
2624
const result = executables.list().find(x => x === 'iam-executable-in-sub-folder')
27-
return expect(result).toBeFalsy()
25+
expect(result).toBeFalsy()
2826
})
2927
})
3028

3129
describe('documentation', () => {
3230
it('uses `man` so it disregards the PATH it has been initialized with', async () => {
33-
expect.assertions(1)
34-
const executables = await executablesPromise
3531
const result = await executables.documentation('ls')
36-
return expect(result).toBeTruthy()
32+
expect(result).toBeTruthy()
3733
})
3834
})
3935

4036
describe('isExecutableOnPATH', () => {
4137
it('looks at the PATH it has been initialized with', async () => {
42-
expect.assertions(1)
43-
const executables = await executablesPromise
4438
const result = executables.isExecutableOnPATH('ls')
45-
return expect(result).toEqual(false)
39+
expect(result).toEqual(false)
4640
})
4741
})

0 commit comments

Comments
 (0)