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
Next Next commit
refactor(testing): add custom snapshot serializer and serializer op…
…tion to `snapshotTest`
  • Loading branch information
c4spar committed Jun 2, 2023
commit 06f9a8c561279b1bc7d3affa5fb42225624a105b
196 changes: 93 additions & 103 deletions command/test/integration/__snapshots__/test.ts.snap

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions prompt/test/integration/__snapshots__/checkbox_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const snapshot = {};

snapshot[`checkbox prompt > should check an option 1`] = `
"stdout:
? Select an option
stdout:
"? Select an option
❯ ✘ Foo
✘ Bar
✘ Baz\\x1b[3A\\x1b[19G\\x1b[?25l\\x1b[G\\x1b[0J
Expand All @@ -19,7 +19,7 @@ snapshot[`checkbox prompt > should check an option 1`] = `
✘ Bar
❯ ✔ Baz\\x1b[3A\\x1b[19G\\x1b[?25l\\x1b[G\\x1b[0J
? Select an option › Baz
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
24 changes: 12 additions & 12 deletions prompt/test/integration/__snapshots__/confirm_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
export const snapshot = {};

snapshot[`confirm prompt > should confirm 1`] = `
"stdout:
? Please confirm (y/N) ›
stdout:
"? Please confirm (y/N) ›
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
? Please confirm (y/N) › yes
❯ some hint\\x1b[1A\\x1b[27G\\x1b[G\\x1b[0J
? Please confirm (y/N) › Yes
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

snapshot[`confirm prompt > should not confirm 1`] = `
"stdout:
? Please confirm (y/N) ›
stdout:
"? Please confirm (y/N) ›
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
? Please confirm (y/N) › no
❯ some hint\\x1b[1A\\x1b[27G\\x1b[G\\x1b[0J
? Please confirm (y/N) › No
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

snapshot[`confirm prompt > should not confirm by default 1`] = `
"stdout:
? Please confirm (y/N) ›
stdout:
"? Please confirm (y/N) ›
❯ some hint\\x1b[1A\\x1b[26G\\x1b[G\\x1b[0J
? Please confirm (y/N) › No
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
46 changes: 23 additions & 23 deletions prompt/test/integration/__snapshots__/input_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
export const snapshot = {};

snapshot[`input prompt > should enter some text 1`] = `
"stdout:
? Whats your name? (foo) › \\x1b[28G\\x1b[G\\x1b[0J
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
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

snapshot[`input prompt with suggestions > should enable suggestions and list 1`] = `
"stdout:
? Whats your name? (foo) ›
stdout:
"? Whats your name? (foo) ›
foo
bar
baz\\x1b[3A\\x1b[28G\\x1b[G\\x1b[0J
? Whats your name? (foo) › foo
❯ foo\\x1b[1A\\x1b[31G\\x1b[G\\x1b[0J
? Whats your name? (foo) › foo
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

snapshot[`input prompt with prefix > should change prefix 1`] = `
"stdout:
PREFIX Whats your name? (foo) › \\x1b[33G\\x1b[G\\x1b[0J
stdout:
"PREFIX Whats your name? (foo) › \\x1b[33G\\x1b[G\\x1b[0J
PREFIX Whats your name? (foo) › bar\\x1b[36G\\x1b[G\\x1b[0J
PREFIX Whats your name? (foo) › bar
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

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

stdout:
""
stderr:
? Whats your name? (foo) › \\x1b[28G\\x1b[G\\x1b[0J
"? 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"
`;

snapshot[`input prompt without prefix > should disable prefix 1`] = `
"stdout:
Whats your name? (foo) › \\x1b[26G\\x1b[G\\x1b[0J
stdout:
"Whats your name? (foo) › \\x1b[26G\\x1b[G\\x1b[0J
Whats your name? (foo) › bar\\x1b[29G\\x1b[G\\x1b[0J
Whats your name? (foo) › bar
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

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
stdout:
"? Works without --location? (hope so) › \\x1b[41G\\x1b[G\\x1b[0J
? Works without --location? (hope so) › yes\\x1b[44G\\x1b[G\\x1b[0J
? Works without --location? (hope so) › yes
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
8 changes: 4 additions & 4 deletions prompt/test/integration/__snapshots__/list_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const snapshot = {};

snapshot[`list prompt > should enter some keywords 1`] = `
"stdout:
? Enter some keywords (foo, far) ›
stdout:
"? Enter some keywords (foo, far) ›
❯ some hint...\\x1b[1A\\x1b[36G\\x1b[G\\x1b[0J
? Enter some keywords (foo, far) › foo, bar
❯ some hint...\\x1b[1A\\x1b[44G\\x1b[G\\x1b[0J
? Enter some keywords (foo, far) › foo, bar
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
16 changes: 8 additions & 8 deletions prompt/test/integration/__snapshots__/number_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const snapshot = {};

snapshot[`number prompt > should enter a number 1`] = `
"stdout:
? How old are you? (7) › \\x1b[26G\\x1b[G\\x1b[0J
stdout:
"? How old are you? (7) › \\x1b[26G\\x1b[G\\x1b[0J
? How old are you? (7) › 19\\x1b[28G\\x1b[G\\x1b[0J
? How old are you? (7) › 20\\x1b[27G\\x1b[G\\x1b[0J
? How old are you? (7) › 21\\x1b[27G\\x1b[G\\x1b[0J
Expand All @@ -14,21 +14,21 @@ snapshot[`number prompt > should enter a number 1`] = `
? How old are you? (7) › 19\\x1b[27G\\x1b[G\\x1b[0J
? How old are you? (7) › 20\\x1b[27G\\x1b[G\\x1b[0J
? How old are you? (7) › 20
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;

snapshot[`number prompt with float > should enter a floating number 1`] = `
"stdout:
? How old are you? (7) › \\x1b[26G\\x1b[G\\x1b[0J
stdout:
"? How old are you? (7) › \\x1b[26G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.\\x1b[29G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.1\\x1b[29G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.2\\x1b[29G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.3\\x1b[29G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.4\\x1b[29G\\x1b[G\\x1b[0J
? How old are you? (7) › 19.4
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
18 changes: 12 additions & 6 deletions prompt/test/integration/__snapshots__/prompt_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
export const snapshot = {};

snapshot[`prompt method > should check an option 1`] = `
'stdout:
[checkbox:before] input is: foo
{ input: "foo", number: 43, confirm: true, toggle: true, checkbox: [ "bar", "baz" ] }

stdout:
'[checkbox:before] input is: foo
{
input: "foo",
number: 43,
confirm: true,
toggle: true,
checkbox: [ "bar", "baz" ]
}
'
stderr:
? Enter some text (default value) › \\x1b[37G\\x1b[G\\x1b[0J
"? Enter some text (default value) › \\x1b[37G\\x1b[G\\x1b[0J
? Enter some text (default value) › f\\x1b[38G\\x1b[G\\x1b[0J
? Enter some text (default value) › fo\\x1b[39G\\x1b[G\\x1b[0J
? Enter some text (default value) › foo\\x1b[40G\\x1b[G\\x1b[0J
Expand Down Expand Up @@ -48,5 +54,5 @@ stderr:
✔ Bar
❯ ✔ Baz\\x1b[3A\\x1b[19G\\x1b[?25l\\x1b[G\\x1b[0J
? Select an option › Bar, Baz
\\x1b[?25h\\x1b[?25h\\x1b[?25h'
\\x1b[?25h\\x1b[?25h\\x1b[?25h"
`;
8 changes: 4 additions & 4 deletions prompt/test/integration/__snapshots__/secret_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const snapshot = {};

snapshot[`secret prompt > should enter a secret 1`] = `
"stdout:
? enter your secret › \\x1b[23G\\x1b[G\\x1b[0J
stdout:
"? enter your secret › \\x1b[23G\\x1b[G\\x1b[0J
? enter your secret › ***\\x1b[26G\\x1b[G\\x1b[0J
? enter your secret › ***
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
8 changes: 4 additions & 4 deletions prompt/test/integration/__snapshots__/select_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const snapshot = {};

snapshot[`select prompt > should select an option 1`] = `
"stdout:
? Select an option
stdout:
"? Select an option
❯ Foo
Bar
Baz\\x1b[3A\\x1b[19G\\x1b[?25l\\x1b[G\\x1b[0J
Expand All @@ -15,7 +15,7 @@ snapshot[`select prompt > should select an option 1`] = `
Bar
❯ Baz\\x1b[3A\\x1b[19G\\x1b[?25l\\x1b[G\\x1b[0J
? Select an option › Baz
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
8 changes: 4 additions & 4 deletions prompt/test/integration/__snapshots__/toggle_test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const snapshot = {};

snapshot[`toggle prompt > should toggle the prompt 1`] = `
"stdout:
? Please confirm (No) › No / Yes
stdout:
"? Please confirm (No) › No / Yes
❯ some hint\\x1b[1A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J
? Please confirm (No) › No / Yes
❯ some hint\\x1b[1A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J
Expand All @@ -11,7 +11,7 @@ snapshot[`toggle prompt > should toggle the prompt 1`] = `
? Please confirm (No) › No / Yes
❯ some hint\\x1b[1A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J
? Please confirm (No) › Yes
\\x1b[?25h\\x1b[?25h
\\x1b[?25h\\x1b[?25h"
stderr:
"
""
`;
Loading