Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.

Commit 5156b2f

Browse files
committed
test: skip cycles
1 parent e138424 commit 5156b2f

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

test/fixtures/cycle-a.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"name": "@example/cycle-a",
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@example/cycle-b": "*"
7+
}
8+
}

test/fixtures/cycle-b.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"name": "@example/cycle-b",
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@example/cycle-a": "*"
7+
}
8+
}

test/fixtures/deep.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"name": "@example/deep",
44
"version": "0.0.0",
55
"dependencies": {
6-
"@example/basic": "*"
6+
"@example/basic": "*",
7+
"@example/with-preinstall-script": "*"
78
},
89
"allowScripts": {
910
"@example/basic": "*",

test/fixtures/with-cycles.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"private": true,
3+
"name": "@example/with-cycles",
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@example/cycle-a": "*",
7+
"@example/cycle-b": "*",
8+
"@example/with-install-script": "*"
9+
},
10+
"allowScripts": {
11+
"@example/with-install-script": "*"
12+
}
13+
}

test/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ describe('allow-scripts', () => {
7777
expect(fixture.getLog()).not.to.contain('without-install-scripts');
7878
});
7979

80+
it('executes allowed scripts (skips cycles)', async () => {
81+
82+
const fixture = Fixtures.setup('with-cycles', [
83+
'cycle-a',
84+
'cycle-b',
85+
'with-install-script'
86+
]);
87+
88+
await Allow.run({});
89+
90+
expect(fixture.getActualResult()).to.equal('install from with-install-script');
91+
expect(fixture.getLog()).to.contain('skip node_modules/@example/cycle-a (because it has a cycle in dependencies)');
92+
expect(fixture.getLog()).to.contain('skip node_modules/@example/cycle-b (because it has a cycle in dependencies)');
93+
});
94+
8095
it('crashes on script not in allowed list', async () => {
8196

8297
const fixture = Fixtures.setup('not-in-allowed', [

0 commit comments

Comments
 (0)