Last active
April 12, 2023 09:50
-
-
Save matteodepalo/4dbcc035698fe401031b6561dba97be3 to your computer and use it in GitHub Desktop.
Code example 2
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
const ARROW_DOWN = '\u001B[B' | |
const ENTER = '\r' | |
describe('SelectPrompt', async () => { | |
test('choose an answer', async () => { | |
const onEnter = vi.fn() | |
const items = [ | |
{label: 'first', value: 'first'}, | |
{label: 'second', value: 'second'}, | |
{label: 'third', value: 'third'}, | |
] | |
const infoTable = {Add: ['new-ext'], Remove: ['integrated-demand-ext', 'order-discount']} | |
const renderInstance = render( | |
<SelectPrompt | |
message="Associate your project with the org Castile Ventures?" | |
choices={items} | |
infoTable={infoTable} | |
onSubmit={onEnter} | |
/>, | |
) | |
await waitForInputsToBeReady() | |
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN) | |
await sendInputAndWaitForChange(renderInstance, ENTER) | |
expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(` | |
"? Associate your project with the org Castile Ventures? | |
✔ second | |
" | |
`) | |
expect(onEnter).toHaveBeenCalledWith(items[1]!.value) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment