Skip to content

Commit

Permalink
Use regex to make test pass in VSCode (#9791)
Browse files Browse the repository at this point in the history
Tobbe authored and jtoar committed Jan 3, 2024
1 parent 91d0f06 commit 03e3c52
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/cli-packages/dataMigrate/src/__tests__/install.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type yargs from 'yargs'

import * as installCommand from '../commands/install'
import { handler as dataMigrateInstallHandler } from '../commands/installHandler.js'

@@ -24,12 +26,24 @@ describe('install', () => {
})

it('`builder` has an epilogue', () => {
const yargs = { epilogue: jest.fn() }
// @ts-expect-error this is a test file; epilogue is the only thing `builder` calls right now
// The typecasting here is to make TS happy when calling `builder(yargs)`
// further down. We know that only `epilogue` will be called.
const yargs = { epilogue: jest.fn() } as unknown as yargs.Argv

installCommand.builder(yargs)
expect(yargs.epilogue).toBeCalledWith(
// eslint-disable-next-line no-irregular-whitespace
'Also see the Redwood CLI Reference (​https://redwoodjs.com/docs/cli-commands#datamigrate-install​)'

// The epilogue is a string that contains a link to the docs. The string
// contains special control characters when rendered in a terminal that
// supports clickable links. We use regular expressions and wildcards here
// to avoid having to match control characters that might not even always
// be there
expect(yargs.epilogue).toHaveBeenCalledWith(
expect.stringMatching(/Also see the .*Redwood CLI Reference.*/)
)
expect(yargs.epilogue).toHaveBeenCalledWith(
expect.stringMatching(
/https:\/\/redwoodjs\.com\/docs\/cli-commands#datamigrate-install/
)
)
})

0 comments on commit 03e3c52

Please sign in to comment.