Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 23, 2024
1 parent c6cbc8b commit b3fe783
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fixtures/pnpm/multi-lockfile/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# npm / pnpm settings here

# as a library, we want to make sure we explicitly handle peers,
# and not rely on hidden behavior of package-managers.
auto-install-peers=false

# we never want to use packages from the registry over what's in the workspace
prefer-workspaces-packages=true

# default is true, we do this to try to have more isolation
# since we test with incompatible sets of TS types.
shared-workspace-lockfile=false

3 changes: 3 additions & 0 deletions fixtures/pnpm/multi-lockfile/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"private": true
}
4 changes: 4 additions & 0 deletions fixtures/pnpm/multi-lockfile/packages/a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "a",
"version": "0.0.1"
}
4 changes: 4 additions & 0 deletions fixtures/pnpm/multi-lockfile/packages/b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "b",
"version": "0.0.1"
}
5 changes: 5 additions & 0 deletions fixtures/pnpm/multi-lockfile/packages/c/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "c",
"version": "0.0.1"
}

2 changes: 2 additions & 0 deletions fixtures/pnpm/multi-lockfile/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- './packages/*'
4 changes: 4 additions & 0 deletions fixtures/pnpm/single-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "foo-package",
"version": "0.0.1"
}
2 changes: 2 additions & 0 deletions fixtures/pnpm/single-package/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- '.'
88 changes: 88 additions & 0 deletions src/interdep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,93 @@ describe('interdep', function () {
`,
);
});

describe('pnpm/fixtures/single-package', function () {
it('can load the workspaces', function () {
const answer = getPackages('./fixtures/pnpm/single-package');

expect(Array(...answer.keys())).toMatchInlineSnapshot(`
[
"foo-package",
]
`);

expect(answer.get('foo-package')).toMatchInlineSnapshot(
{
pkg: expect.any(Object),
version: expect.any(String),
},
`
{
"isDependencyOf": Map {},
"isPeerDependencyOf": Map {},
"pkg": Any<Object>,
"pkgJSONPath": "./fixtures/pnpm/single-package/package.json",
"version": Any<String>,
}
`,
);
});
});

describe('pnpm/fixtures/multi-lockfile', function () {
it('can load the workspaces', function () {
const answer = getPackages('./fixtures/pnpm/multi-lockfile');

expect(Array(...answer.keys())).toMatchInlineSnapshot(`
[
"a",
"b",
"c",
]
`);

expect(answer.get('a')).toMatchInlineSnapshot(
{
pkg: expect.any(Object),
version: expect.any(String),
},
`
{
"isDependencyOf": Map {},
"isPeerDependencyOf": Map {},
"pkg": Any<Object>,
"pkgJSONPath": "./fixtures/pnpm/multi-lockfile/packages/a/package.json",
"version": Any<String>,
}
`,
);
expect(answer.get('b')).toMatchInlineSnapshot(
{
pkg: expect.any(Object),
version: expect.any(String),
},
`
{
"isDependencyOf": Map {},
"isPeerDependencyOf": Map {},
"pkg": Any<Object>,
"pkgJSONPath": "./fixtures/pnpm/multi-lockfile/packages/b/package.json",
"version": Any<String>,
}
`,
);
expect(answer.get('c')).toMatchInlineSnapshot(
{
pkg: expect.any(Object),
version: expect.any(String),
},
`
{
"isDependencyOf": Map {},
"isPeerDependencyOf": Map {},
"pkg": Any<Object>,
"pkgJSONPath": "./fixtures/pnpm/multi-lockfile/packages/c/package.json",
"version": Any<String>,
}
`,
);
});
});
});
});

0 comments on commit b3fe783

Please sign in to comment.