-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from ngirardin/better-version-detection
fix: Add better version detection
- Loading branch information
Showing
2 changed files
with
108 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { afterEach, describe, expect, it, vi } from 'vitest' | ||
import { spawnVitestVersion } from '../src/pure/utils' | ||
|
||
afterEach(() => { | ||
vi.restoreAllMocks() | ||
}) | ||
|
||
// Mock vscode ("pure" modules aren't quite pure) | ||
vi.mock('vscode', () => { | ||
return { | ||
default: { myDefaultKey: vi.fn() }, | ||
namedExport: vi.fn(), | ||
window: { | ||
createOutputChannel: () => { | ||
return { | ||
appendLine: vi.fn(), | ||
} | ||
}, | ||
}, | ||
} | ||
}) | ||
|
||
describe('utils', () => { | ||
describe('spawnVitestVersion', () => { | ||
it('should return undefined when passing an unkown command', async () => { | ||
const result = await spawnVitestVersion('unknown-command', ['xxx'], {}) | ||
expect(result).toBeUndefined() | ||
}) | ||
|
||
it('should return undefined when the commmand don\'t return any version', async () => { | ||
const result = await spawnVitestVersion('/bin/ls', ['-l'], {}) | ||
expect(result).toBeUndefined() | ||
}) | ||
}) | ||
|
||
// TODO mock spawn | ||
// describe('xxx', () => { | ||
// const spy = vi.mock('childProcess', 'spawnSync', (a, b) => vi.fn()) | ||
|
||
// it('should return the version when the command return a version', async () => { | ||
// await expect(() => tryBoth('xxx', ['a', 'b'], { one: '1', two: '2' })).rejects.toThrowError('xx') | ||
|
||
// expect(spy).toHaveBeenCalledTimes(2) | ||
// }) | ||
// }) | ||
}) |