From 9fb5b2dd2b4bd58d6a595d68b1a1019e41af1caf Mon Sep 17 00:00:00 2001 From: zhyupe Date: Wed, 31 Jan 2024 23:29:16 +0800 Subject: [PATCH] fix: packager detect tests are not running (#199) --- test/programmatic/__snapshots__/detect.spec.ts.snap | 4 ++-- test/programmatic/detect.spec.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/programmatic/__snapshots__/detect.spec.ts.snap b/test/programmatic/__snapshots__/detect.spec.ts.snap index e4038e2b..845725dd 100644 --- a/test/programmatic/__snapshots__/detect.spec.ts.snap +++ b/test/programmatic/__snapshots__/detect.spec.ts.snap @@ -20,10 +20,10 @@ exports[`packager > npm 1`] = `"npm"`; exports[`packager > pnpm 1`] = `"pnpm"`; -exports[`packager > pnpm@6 1`] = `"pnpm"`; +exports[`packager > pnpm@6 1`] = `"pnpm@6"`; exports[`packager > unknown 1`] = `null`; exports[`packager > yarn 1`] = `"yarn"`; -exports[`packager > yarn@berry 1`] = `"yarn"`; +exports[`packager > yarn@berry 1`] = `"yarn@berry"`; diff --git a/test/programmatic/detect.spec.ts b/test/programmatic/detect.spec.ts index 4b7799a6..de489d3b 100644 --- a/test/programmatic/detect.spec.ts +++ b/test/programmatic/detect.spec.ts @@ -7,11 +7,11 @@ import { AGENTS, detect } from '../../src' let basicLog: SpyInstance, errorLog: SpyInstance, warnLog: SpyInstance, infoLog: SpyInstance -function detectTest(agent: string) { +function detectTest(fixture: string, agent: string) { return async () => { const cwd = await fs.mkdtemp(path.join(tmpdir(), 'ni-')) - const fixture = path.join(__dirname, '..', 'fixtures', 'lockfile', agent) - await fs.copy(fixture, cwd) + const dir = path.join(__dirname, '..', 'fixtures', fixture, agent) + await fs.copy(dir, cwd) expect(await detect({ programmatic: true, cwd })).toMatchSnapshot() } @@ -33,7 +33,7 @@ const fixtures = ['lockfile', 'packager'] // matrix testing of: fixtures x agents fixtures.forEach(fixture => describe(fixture, () => agents.forEach((agent) => { - it(agent, detectTest(agent)) + it(agent, detectTest(fixture, agent)) it('no logs', () => { expect(basicLog).not.toHaveBeenCalled()