Skip to content

Commit

Permalink
chore: update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
fireairforce committed Oct 27, 2023
1 parent 5bd41ad commit 3ffa523
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
Expand Up @@ -76,8 +76,8 @@ export function getUpdateChoices (outdatedPkgsOfProjects: OutdatedPackage[], wor
}
})

// To filter out selected "dependencies", "devDependencies", "packageManager" in the final output,
// we rename it here to "[dependencies]", "[devDependencies]" and "packageManager"
// To filter out selected "dependencies", "devDependencies" and "packageManager" in the final output,
// we rename it here to "[dependencies]", "[devDependencies]" and "[packageManager]"
// which will be filtered out in the format function of the prompt.
finalChoices.push({ name: `[${depGroup}]`, choices, message: depGroup })

Expand Down
82 changes: 43 additions & 39 deletions pkg-manager/plugin-commands-installation/test/update/interactive.ts
Expand Up @@ -11,7 +11,7 @@ import * as enquirer from 'enquirer'
jest.mock('enquirer', () => ({ prompt: jest.fn() }))

// eslint-disable-next-line
const prompt = enquirer.prompt as any
const prompt = enquirer.prompt as any;

const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`

Expand Down Expand Up @@ -311,27 +311,25 @@ test('interactively update should ignore dependencies from the ignoreDependencie
storeDir,
})

expect(prompt.mock.calls[0][0].choices).toStrictEqual(
[
{
choices: [
{
disabled: true,
hint: '',
name: 'Package Current Target URL ',
value: '',
},
{
message: chalk`micromatch 3.0.0 ❯ 3.{yellowBright.bold 1.10} `,
value: 'micromatch',
name: 'micromatch',
},
],
name: '[dependencies]',
message: 'dependencies',
},
]
)
expect(prompt.mock.calls[0][0].choices).toStrictEqual([
{
choices: [
{
disabled: true,
hint: '',
name: 'Package Current Target URL ',
value: '',
},
{
message: chalk`micromatch 3.0.0 ❯ 3.{yellowBright.bold 1.10} `,
value: 'micromatch',
name: 'micromatch',
},
],
name: '[dependencies]',
message: 'dependencies',
},
])

expect(prompt).toBeCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -363,13 +361,6 @@ test('interactively update should update corepack config', async () => {

const storeDir = path.resolve('pnpm-store')

const headerChoice = {
name: 'Package Current Target URL ',
disabled: true,
hint: '',
value: '',
}

await add.handler(
{
...DEFAULT_OPTIONS,
Expand Down Expand Up @@ -402,20 +393,33 @@ test('interactively update should update corepack config', async () => {
storeDir,
})

expect(prompt.mock.calls[0][0].choices).toStrictEqual([
const promptStr = JSON.stringify(prompt.mock.calls[0][0].choices[0])
const latestVersionIndex = promptStr.indexOf('❯')
const latestVersion = promptStr.substring(
latestVersionIndex + 2,
latestVersionIndex + 7
)
const promptChoices = JSON.parse(promptStr.replace(latestVersion, '8.9.0'))

expect(promptChoices).toMatchInlineSnapshot(`
{
choices: [
headerChoice,
"choices": [
{
message: chalk`pnpm 8.7.0 ❯ 8.9.2 `,
value: 'pnpm',
name: 'pnpm',
"disabled": true,
"hint": "",
"name": "Package Current Target URL ",
"value": "",
},
{
"message": "pnpm 8.7.0 ❯ 8.9.0 ",
"name": "pnpm",
"value": "pnpm",
},
],
name: '[packageManager]',
message: 'packageManager',
},
])
"message": "packageManager",
"name": "[packageManager]",
}
`)
expect(prompt).toBeCalledWith(
expect.objectContaining({
footer: '\nEnter to start updating. Ctrl-c to cancel.',
Expand Down

0 comments on commit 3ffa523

Please sign in to comment.