-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unused imports * Update hunspell-lib * Add unit tests for app.ts * Make snapshots of compiled output. * Update package-lock.json * Normalize snapshots * Do not snapshot output -- issues with posix vs win32 cspell:ignore posix
- Loading branch information
Showing
6 changed files
with
163 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,60 @@ | ||
import * as app from './app'; | ||
import * as Commander from 'commander'; | ||
import * as path from 'path'; | ||
|
||
const projectRoot = path.join(__dirname, '..'); | ||
const pathSamples = path.join(projectRoot, 'Samples'); | ||
const pathTemp = path.join(projectRoot, 'temp'); | ||
|
||
function argv(...args: string[]): string[] { | ||
return [...process.argv.slice(0, 2), ...args]; | ||
} | ||
|
||
function getCommander() { | ||
return new Commander.Command; | ||
} | ||
|
||
describe('Validate the application', () => { | ||
test('test app compile-trie', async () => { | ||
const commander = getCommander(); | ||
const log = jest.spyOn(console, 'log').mockImplementation(); | ||
const args = argv('compile-trie', '-n', path.join(pathSamples, 'cities.txt'), '-o', pathTemp); | ||
await expect(app.run(commander, args)).resolves.toBeUndefined(); | ||
expect(log).toHaveBeenCalled(); | ||
log.mockRestore(); | ||
}); | ||
|
||
test('test app compile', async () => { | ||
const commander = getCommander(); | ||
const log = jest.spyOn(console, 'log').mockImplementation(); | ||
const args = argv('compile', '-n', path.join(pathSamples, 'cities.txt'), '-o', pathTemp); | ||
await expect(app.run(commander, args)).resolves.toBeUndefined(); | ||
expect(log).toHaveBeenCalled(); | ||
log.mockRestore(); | ||
}); | ||
|
||
test('test app no args', () => { | ||
const commander = getCommander(); | ||
const mock = jest.fn(); | ||
commander.on('--help', mock); | ||
expect(app.run(commander, argv())).rejects.toThrowError(Commander.CommanderError); | ||
expect(mock.mock.calls.length).toBe(1); | ||
}); | ||
|
||
test('test app --help', async () => { | ||
const commander = getCommander(); | ||
const mock = jest.fn(); | ||
commander.on('--help', mock); | ||
await expect(app.run(commander, argv('--help'))).rejects.toThrowError(Commander.CommanderError); | ||
expect(mock.mock.calls.length).toBe(1); | ||
}); | ||
|
||
test('test app -V', async () => { | ||
const commander = getCommander(); | ||
const mock = jest.fn(); | ||
commander.on('option:version', mock); | ||
await expect(app.run(commander, argv('-V')) ).rejects.toThrowError(Commander.CommanderError); | ||
expect(mock.mock.calls.length).toBe(1); | ||
}); | ||
|
||
}); |
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