Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some refactorings and fixes
  • Loading branch information
c4spar committed Apr 3, 2023
commit 361c83218437a5b2f0fa1ea05ead20d21d528220
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - checkbox_test.ts 1`] = `
snapshot[`checkbox prompt > should check an option 1`] = `
"stdout:
? Select an option
❯ ✘ Foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - checkbox_test.ts 1`] = `
snapshot[`checkbox prompt > should check an option 1`] = `
"stdout:
? Select an option
❯ × Foo
Expand Down
6 changes: 3 additions & 3 deletions prompt/test/integration/__snapshots__/confirm_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - confirm_test.ts 1`] = `
snapshot[`confirm prompt > should confirm 1`] = `
"stdout:
? Please confirm (y/N) ›
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
Expand All @@ -12,7 +12,7 @@ stderr:
"
`;

snapshot[`assert prompt snapshot - confirm_test.ts 2`] = `
snapshot[`confirm prompt > should not confirm 1`] = `
"stdout:
? Please confirm (y/N) ›
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
Expand All @@ -24,7 +24,7 @@ stderr:
"
`;

snapshot[`assert prompt snapshot - confirm_test.ts 3`] = `
snapshot[`confirm prompt > should not confirm by default 1`] = `
"stdout:
? Please confirm (y/N) ›
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - confirm_test.ts 1`] = `
snapshot[`confirm prompt > should confirm 1 1`] = `
"stdout:
? Please confirm (y/N) »
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
Expand All @@ -12,7 +12,7 @@ stderr:
"
`;

snapshot[`assert prompt snapshot - confirm_test.ts 2`] = `
snapshot[`confirm prompt 2`] = `
"stdout:
? Please confirm (y/N) »
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
Expand All @@ -24,7 +24,7 @@ stderr:
"
`;

snapshot[`assert prompt snapshot - confirm_test.ts 3`] = `
snapshot[`confirm prompt 3`] = `
"stdout:
? Please confirm (y/N) »
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_no_location_flag_test.ts 1`] = `
snapshot[`input prompt with no location flag > should work without --location flag 1`] = `
"stdout:
? Works without --location? (hope so) › \\x1b[41G\\x1b[G\\x1b[0J
? Works without --location? (hope so) › yes\\x1b[44G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_no_location_flag_test.ts 1`] = `
snapshot[`input prompt with no location flag > should work without --location flag 1`] = `
"stdout:
? Works without --location? (hope so) » \\x1b[41G\\x1b[G\\x1b[0J
? Works without --location? (hope so) » yes\\x1b[44G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_no_prefix_test.ts 1`] = `
snapshot[`input prompt without prefix > should disable prefix 1`] = `
"stdout:
Whats your name? (foo) › \\x1b[26G\\x1b[G\\x1b[0J
Whats your name? (foo) › bar\\x1b[29G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_no_prefix_test.ts 1`] = `
snapshot[`input prompt without prefix > should disable prefix 1`] = `
"stdout:
Whats your name? (foo) » \\x1b[26G\\x1b[G\\x1b[0J
Whats your name? (foo) » bar\\x1b[29G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_output_stream_test.ts 1`] = `
snapshot[`input prompt with writer set to stderr > should enter some text 1`] = `
"stdout:

stderr:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_output_stream_test.ts 1`] = `
snapshot[`input prompt with writer set to stderr > should enter some text 1`] = `
"stdout:

stderr:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_prefix_test.ts 1`] = `
snapshot[`input prompt with prefix > should change prefix 1`] = `
"stdout:
PREFIX Whats your name? (foo) › \\x1b[33G\\x1b[G\\x1b[0J
PREFIX Whats your name? (foo) › bar\\x1b[36G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_prefix_test.ts 1`] = `
snapshot[`input prompt with prefix > should change prefix 1`] = `
"stdout:
PREFIX Whats your name? (foo) » \\x1b[33G\\x1b[G\\x1b[0J
PREFIX Whats your name? (foo) » bar\\x1b[36G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_suggestions_test.ts 1`] = `
snapshot[`input prompt with suggestions > should enable suggestions and list 1`] = `
"stdout:
? Whats your name? (foo) ›
foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_suggestions_test.ts 1`] = `
snapshot[`input prompt with suggestions > should enable suggestions and list 1`] = `
"stdout:
? Whats your name? (foo) »
foo
Expand Down
12 changes: 11 additions & 1 deletion prompt/test/integration/__snapshots__/input_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_test.ts 1`] = `
snapshot[`input prompt > should enter som text 1`] = `
"stdout:
? Whats your name? (foo) › \\x1b[28G\\x1b[G\\x1b[0J
? Whats your name? (foo) › foo bar\\x1b[35G\\x1b[G\\x1b[0J
? Whats your name? (foo) › foo bar
\\x1b[?25h\\x1b[?25h
stderr:
"
`;

snapshot[`second input prompt > should enter som text 1`] = `
"stdout:
? Whats your name? (foo) › \\x1b[28G\\x1b[G\\x1b[0J
? Whats your name? (foo) › foo bar\\x1b[35G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - input_test.ts 1`] = `
snapshot[`input prompt > should enter som text 1`] = `
"stdout:
? Whats your name? (foo) » \\x1b[28G\\x1b[G\\x1b[0J
? Whats your name? (foo) » foo bar\\x1b[35G\\x1b[G\\x1b[0J
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/__snapshots__/list_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - list_test.ts 1`] = `
snapshot[`list prompt > should enter some keywords 1`] = `
"stdout:
? Enter some keywords (foo, far) ›
❯ some hint...\\x1b[1A\\x1b[36G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - list_test.ts 1`] = `
snapshot[`list prompt > should enter some keywords 1`] = `
"stdout:
? Enter some keywords (foo, far) »
❯ some hint...\\x1b[1A\\x1b[36G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - number_decimal_test.ts 1`] = `
snapshot[`number prompt with float > should enter a floating number 1`] = `
"stdout:
? How old are you? (7) › \\x1b[26G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.\\x1b[29G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - number_decimal_test.ts 1`] = `
snapshot[`number prompt with float > should enter a floating number 1`] = `
"stdout:
? How old are you? (7) » \\x1b[26G\\x1b[G\\x1b[0J
? How old are you? (7) » 19.\\x1b[29G\\x1b[G\\x1b[0J
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/__snapshots__/number_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - number_test.ts 1`] = `
snapshot[`number prompt > should enter a number 1`] = `
"stdout:
? How old are you? (7) › \\x1b[26G\\x1b[G\\x1b[0J
? How old are you? (7) › 19\\x1b[28G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - number_test.ts 1`] = `
snapshot[`number prompt > should enter a number 1`] = `
"stdout:
? How old are you? (7) » \\x1b[26G\\x1b[G\\x1b[0J
? How old are you? (7) » 19\\x1b[28G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - prompt_list_test.ts 1`] = `
snapshot[`prompt list > should check an option 1`] = `
'stdout:
[checkbox:before] input is: foo
{ input: "foo", number: 43, confirm: true, toggle: true, checkbox: [ "bar", "baz" ] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - prompt_list_test.ts 1`] = `
snapshot[`prompt list > should check an option 1`] = `
'stdout:
[checkbox:before] input is: foo
{ input: "foo", number: 43, confirm: true, toggle: true, checkbox: [ "bar", "baz" ] }
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/__snapshots__/secret_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - secret_test.ts 1`] = `
snapshot[`secret prompt > should enter a secret 1`] = `
"stdout:
? enter your secret › \\x1b[23G\\x1b[G\\x1b[0J
? enter your secret › ***\\x1b[26G\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - secret_test.ts 1`] = `
snapshot[`secret prompt > should enter a secret 1`] = `
"stdout:
? enter your secret » \\x1b[23G\\x1b[G\\x1b[0J
? enter your secret » ***\\x1b[26G\\x1b[G\\x1b[0J
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/__snapshots__/select_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - select_test.ts 1`] = `
snapshot[`select prompt > should select an option 1`] = `
"stdout:
? Select an option
❯ Foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - select_test.ts 1`] = `
snapshot[`select prompt > should select an option 1`] = `
"stdout:
? Select an option
❯ Foo
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/__snapshots__/toggle_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - toggle_test.ts 1`] = `
snapshot[`toggle prompt > should toggle the prompt 1`] = `
"stdout:
? Please confirm (No) › No / Yes
❯ some hint\\x1b[1A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const snapshot = {};

snapshot[`assert prompt snapshot - toggle_test.ts 1`] = `
snapshot[`toggle prompt > should toggle the prompt 1`] = `
"stdout:
? Please confirm (No) » No / Yes
❯ some hint\\x1b[1A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/checkbox_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Checkbox } from "../../checkbox.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "checkbox prompt",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should check an option": ansi
.cursorDown
.cursorDown
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/confirm_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Confirm } from "../../confirm.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "confirm prompt",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should confirm": ["y", "\n"],
"should not confirm": ["n", "\n"],
"should not confirm by default": ["", "\n"],
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/input_no_location_flag_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Input } from "../../input.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "input prompt with no location flag",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should work without --location flag": ["yes", "\n"],
},
async fn() {
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/input_no_prefix_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Input } from "../../input.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "input prompt without prefix",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should disable prefix": ["bar", "\n"],
},
async fn() {
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/input_output_stream_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Input } from "../../input.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "input prompt with writer set to stderr",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should enter some text": ["foo bar", "\n"],
},
async fn() {
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/input_prefix_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Input } from "../../input.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "input prompt with prefix",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should change prefix": ["bar", "\n"],
},
async fn() {
Expand Down
3 changes: 2 additions & 1 deletion prompt/test/integration/input_suggestions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Input } from "../../input.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "input prompt with suggestions",
meta: import.meta,
osSuffix: ["windows"],
tests: {
steps: {
"should enable suggestions and list": ["foo", "\n"],
},
async fn() {
Expand Down
20 changes: 19 additions & 1 deletion prompt/test/integration/input_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,27 @@ import { Input } from "../../input.ts";
import { assertPromptSnapshot } from "../../testing.ts";

await assertPromptSnapshot({
name: "input prompt",
meta: import.meta,
osSuffix: ["windows"],
tests: {
args: [],
steps: {
"should enter som text": ["foo bar", "\n"],
},
async fn() {
await Input.prompt({
message: "Whats your name?",
default: "foo",
});
},
});

await assertPromptSnapshot({
name: "second input prompt",
meta: import.meta,
osSuffix: ["windows"],
args: [],
steps: {
"should enter som text": ["foo bar", "\n"],
},
async fn() {
Expand Down
Loading