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
refactor steps
  • Loading branch information
c4spar committed Apr 4, 2023
commit 7c25a23b833fe2e5694aa8fd447aa2dd6d785f52
16 changes: 7 additions & 9 deletions prompt/test/integration/checkbox_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { Checkbox } from "../../checkbox.ts";
import { assertSnapshotCall } from "../../../testing/assert_snapshot_call.ts";

await assertSnapshotCall({
name: "checkbox prompt",
name: "checkbox prompt > should check an option",
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should check an option": ansi
.cursorDown
.cursorDown
.text(" ")
.text("\n")
.toArray(),
},
stdin: ansi
.cursorDown
.cursorDown
.text(" ")
.text("\n")
.toArray(),
async fn() {
await Checkbox.prompt({
message: "Select an option",
Expand Down
6 changes: 3 additions & 3 deletions prompt/test/integration/confirm_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ await assertSnapshotCall({
osSuffix: ["windows"],
// args: ["--allow-env=ASSERT_SNAPSHOT_CALL_TEST_NAME"],
steps: {
"should confirm": ["y", "\n"],
"should not confirm": ["n", "\n"],
"should not confirm by default": ["", "\n"],
"should confirm": { stdin: ["y", "\n"] },
"should not confirm": { stdin: ["n", "\n"] },
"should not confirm by default": { stdin: ["", "\n"] },
},
async fn() {
await Confirm.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/input_no_location_flag_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should work without --location flag": ["yes", "\n"],
"should work without --location flag": { stdin: ["yes", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/input_no_prefix_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should disable prefix": ["bar", "\n"],
"should disable prefix": { stdin: ["bar", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/input_output_stream_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enter some text": ["foo bar", "\n"],
"should enter some text": { stdin: ["foo bar", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/input_prefix_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should change prefix": ["bar", "\n"],
"should change prefix": { stdin: ["bar", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/input_suggestions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enable suggestions and list": ["foo", "\n"],
"should enable suggestions and list": { stdin: ["foo", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/input_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enter som text": ["foo bar", "\n"],
"should enter som text": { stdin: ["foo bar", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/list_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enter some keywords": ["foo,bar", "\n"],
"should enter some keywords": { stdin: ["foo,bar", "\n"] },
},
async fn() {
await List.prompt({
Expand Down
18 changes: 10 additions & 8 deletions prompt/test/integration/number_decimal_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enter a floating number": ansi
.text("19.")
.cursorUp
.cursorUp
.cursorUp
.cursorUp
.text("\n")
.toArray(),
"should enter a floating number": {
stdin: ansi
.text("19.")
.cursorUp
.cursorUp
.cursorUp
.cursorUp
.text("\n")
.toArray(),
},
},
async fn() {
await Number.prompt({
Expand Down
28 changes: 15 additions & 13 deletions prompt/test/integration/number_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enter a number": ansi
.text("19")
.cursorUp
.text("u")
.cursorDown
.cursorDown
.cursorDown
.cursorDown
.cursorUp
.cursorUp
.cursorUp
.text("\n")
.toArray(),
"should enter a number": {
stdin: ansi
.text("19")
.cursorUp
.text("u")
.cursorDown
.cursorDown
.cursorDown
.cursorDown
.cursorUp
.cursorUp
.cursorUp
.text("\n")
.toArray(),
},
},
async fn() {
await Number.prompt({
Expand Down
52 changes: 27 additions & 25 deletions prompt/test/integration/prompt_list_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,33 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should check an option": ansi
// input
.text("f")
.text("o")
.text("o")
.text("\n")
// number
.text("4")
.text("3")
.text("\n")
// confirm
.text("y")
.text("\n")
// toggle
.text("y")
.text("n")
.text("y")
.text("\n")
// checkbox
.cursorDown
.text(" ")
.cursorDown
.text(" ")
.text("\n")
.toArray(),
"should check an option": {
stdin: ansi
// input
.text("f")
.text("o")
.text("o")
.text("\n")
// number
.text("4")
.text("3")
.text("\n")
// confirm
.text("y")
.text("\n")
// toggle
.text("y")
.text("n")
.text("y")
.text("\n")
// checkbox
.cursorDown
.text(" ")
.cursorDown
.text(" ")
.text("\n")
.toArray(),
},
},
async fn() {
const checkboxOptions: PromptOptions<
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/secret_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should enter a secret": ["123", "\n"],
"should enter a secret": { stdin: ["123", "\n"] },
},
async fn() {
await Secret.prompt({
Expand Down
12 changes: 7 additions & 5 deletions prompt/test/integration/select_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should select an option": ansi
.cursorDown
.cursorDown
.text("\n")
.toArray(),
"should select an option": {
stdin: ansi
.cursorDown
.cursorDown
.text("\n")
.toArray(),
},
},
async fn() {
await Select.prompt({
Expand Down
2 changes: 1 addition & 1 deletion prompt/test/integration/toggle_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ await assertSnapshotCall({
meta: import.meta,
osSuffix: ["windows"],
steps: {
"should toggle the prompt": ["y", "n", "y", "\n"],
"should toggle the prompt": { stdin: ["y", "n", "y", "\n"] },
},
async fn() {
await Toggle.prompt({
Expand Down
2 changes: 1 addition & 1 deletion testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ await assertSnapshotCall({
name: "test name",
meta: import.meta,
steps: {
"should enter som text": ["foo bar", "\n"],
"should enter som text": { stdin: ["foo bar", "\n"] },
},
async fn() {
await Input.prompt({
Expand Down
Loading