-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add runtime test that TypeScript imports are working (#1473)
* Add runtime test that TypeScript imports are working * Add test of default export, have not deleted it yet!
- Loading branch information
1 parent
4aaaa9d
commit c119028
Showing
5 changed files
with
107 additions
and
5 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.
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
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,44 @@ | ||
import { program, Command, Option, CommanderError, InvalidOptionArgumentError, Help, createCommand } from '../'; | ||
|
||
import * as commander from '../'; | ||
|
||
// Do some simple checks that expected imports are available at runtime. | ||
// Similar tests to esm-imports-test.js | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
function checkClass(obj: object, name: string) { | ||
expect(typeof obj).toEqual('object'); | ||
expect(obj.constructor.name).toEqual(name); | ||
} | ||
|
||
test('legacy default export of global Command', () => { | ||
checkClass(commander, 'Command'); | ||
}); | ||
|
||
test('program', () => { | ||
checkClass(program, 'Command'); | ||
}); | ||
|
||
test('createCommand', () => { | ||
checkClass(createCommand(), 'Command'); | ||
}); | ||
|
||
test('Command', () => { | ||
checkClass(new Command('name'), 'Command'); | ||
}); | ||
|
||
test('Option', () => { | ||
checkClass(new Option('-e, --example', 'description'), 'Option'); | ||
}); | ||
|
||
test('CommanderError', () => { | ||
checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError'); | ||
}); | ||
|
||
test('InvalidOptionArgumentError', () => { | ||
checkClass(new InvalidOptionArgumentError('failed'), 'InvalidOptionArgumentError'); | ||
}); | ||
|
||
test('Help', () => { | ||
checkClass(new Help(), 'Help'); | ||
}); |
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