-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ dist | |
.nyc_output | ||
packages/*/node_modules | ||
packages/*/__snapshots__ | ||
*.test-d.ts |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
"outDir": "./dist", | ||
}, | ||
"include": ["./src"] | ||
} |
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,84 @@ | ||
import inquirer from './src/index.js'; | ||
|
||
describe('Library types work properly', () => { | ||
it('input', () => { | ||
expect(() => { | ||
return inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'first_name', | ||
message: "What's your first name", | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'first_name', | ||
message: "What's your first name", | ||
default: 'John', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'first_name', | ||
message: "What's your first name", | ||
/* @ts-expect-error: type shouldn't allow this format */ | ||
default: 6, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'foo', | ||
message: 'foo', | ||
filter(answer: string) { | ||
return 'other string'; | ||
}, | ||
transformer(answer: string, { isFinal }: { isFinal: boolean }) { | ||
return 'other string'; | ||
}, | ||
validate(answer: string) { | ||
return 'oh no'; | ||
}, | ||
when() { | ||
return true; | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'foo', | ||
message: 'foo', | ||
/* @ts-expect-error: type shouldn't allow this format */ | ||
filter(answer: number) { | ||
return 3; | ||
}, | ||
/* @ts-expect-error: type shouldn't allow this format */ | ||
transformer(answer: string) { | ||
return 45; | ||
}, | ||
/* @ts-expect-error: type shouldn't allow this format */ | ||
validate(answer: string) { | ||
return 1; | ||
}, | ||
}, | ||
]); | ||
}).toBeInstanceOf(Function); | ||
}); | ||
|
||
it('select', () => { | ||
expect(() => { | ||
return inquirer.prompt([ | ||
{ | ||
type: 'select', | ||
name: 'ask_last_name', | ||
message: 'Are you willing to share your last name', | ||
choices: [ | ||
{ value: '1', name: 'Yes' }, | ||
{ value: '', name: 'No' }, | ||
], | ||
}, | ||
/* @ts-expect-error: choices option is required */ | ||
{ | ||
type: 'select', | ||
name: 'ask_last_name', | ||
message: 'Are you willing to share your last name', | ||
}, | ||
]); | ||
}).toBeInstanceOf(Function); | ||
}); | ||
}); |
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,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false | ||
}, | ||
"include": ["**/*.test-d.ts"] | ||
} |