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