Skip to content

Commit

Permalink
🔍 adds tests for the max depth option
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Oct 26, 2017
1 parent 2b17885 commit a31d645
Show file tree
Hide file tree
Showing 6 changed files with 860 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/extract/extract-composite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,78 @@ describe('Bundled - ', () => bundledFixtures.forEach(runRecursiveFixture));
describe('AMD recursive - ', () => amdRecursiveFixtures.forEach(runRecursiveFixture));
describe('TypeScript recursive - ', () => tsRecursiveFixtures.forEach(runRecursiveFixture));
describe('CoffeeScript recursive - ', () => coffeeRecursiveFixtures.forEach(runRecursiveFixture));

describe('Max depth', () => {
it('returns the complete graph when max-depth is not specified', () => {
const lResult = extract(
["./test/extract/fixtures/maxDepth/index.js"]
);

expect(lResult.dependencies).to.deep.equal(
require('./maxDepthUnspecified.json').dependencies
);
expect(lResult).to.be.jsonSchema(depSchema);
});

it('returns the file and one deep with --max-depth 1', () => {
const lResult = extract(
["./test/extract/fixtures/maxDepth/index.js"],
{
maxDepth: 1,
maxDepthSpecified: true
}
);

expect(lResult.dependencies).to.deep.equal(
require('./maxDepth1.json').dependencies
);
expect(lResult).to.be.jsonSchema(depSchema);
});

it('returns the file and one deep with --max-depth 2', () => {
const lResult = extract(
["./test/extract/fixtures/maxDepth/index.js"],
{
maxDepth: 2,
maxDepthSpecified: true
}
);

expect(lResult.dependencies).to.deep.equal(
require('./maxDepth2.json').dependencies
);
expect(lResult).to.be.jsonSchema(depSchema);
});

it('returns the file and one deep with --max-depth 3', () => {
const lResult = extract(
["./test/extract/fixtures/maxDepth/index.js"],
{
maxDepth: 3,
maxDepthSpecified: true
}
);

expect(lResult.dependencies).to.deep.equal(
require('./maxDepth3.json').dependencies
);
expect(lResult).to.be.jsonSchema(depSchema);
});

it('returns the file and one deep with --max-depth 4', () => {
const lResult = extract(
["./test/extract/fixtures/maxDepth/index.js"],
{
maxDepth: 4,
maxDepthSpecified: true
}
);

expect(lResult.dependencies).to.deep.equal(
require('./maxDepth4.json').dependencies
);
expect(lResult).to.be.jsonSchema(depSchema);
});
});

/* eslint global-require: 0*/
97 changes: 97 additions & 0 deletions test/extract/maxDepth1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"dependencies": [
{
"source": "./test/extract/fixtures/maxDepth/index.js",
"dependencies": [
{
"resolved": "test/extract/fixtures/maxDepth/oneAndTwoDeep.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./oneAndTwoDeep",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "test/extract/fixtures/maxDepth/oneDeep.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./oneDeep",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "test/extract/fixtures/maxDepth/sub/oneDeepInSub.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./sub/oneDeepInSub",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "os",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"dependencyTypes": [
"core"
],
"module": "os",
"moduleSystem": "es6",
"valid": true
}
]
},
{
"source": "os",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencyTypes": [
"core"
],
"dependencies": []
},
{
"source": "test/extract/fixtures/maxDepth/oneAndTwoDeep.js",
"dependencies": []
},
{
"source": "test/extract/fixtures/maxDepth/oneDeep.js",
"dependencies": []
},
{
"source": "test/extract/fixtures/maxDepth/sub/oneDeepInSub.js",
"dependencies": []
}
],
"summary": {
"violations": [],
"error": 0,
"warn": 0,
"info": 0,
"totalCruised": 5,
"optionsUsed": {
"outputTo": "./test/extract/maxDepth1.json",
"exclude": "",
"maxDepth": 1,
"system": [
"amd",
"cjs",
"es6"
],
"outputType": "json"
}
}
}
143 changes: 143 additions & 0 deletions test/extract/maxDepth2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"dependencies": [
{
"source": "./test/extract/fixtures/maxDepth/index.js",
"dependencies": [
{
"resolved": "test/extract/fixtures/maxDepth/oneAndTwoDeep.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./oneAndTwoDeep",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "test/extract/fixtures/maxDepth/oneDeep.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./oneDeep",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "test/extract/fixtures/maxDepth/sub/oneDeepInSub.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./sub/oneDeepInSub",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "os",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"dependencyTypes": [
"core"
],
"module": "os",
"moduleSystem": "es6",
"valid": true
}
]
},
{
"source": "os",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencyTypes": [
"core"
],
"dependencies": []
},
{
"source": "test/extract/fixtures/maxDepth/oneAndTwoDeep.js",
"dependencies": []
},
{
"source": "test/extract/fixtures/maxDepth/oneDeep.js",
"dependencies": [
{
"resolved": "test/extract/fixtures/maxDepth/oneAndTwoDeep.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./oneAndTwoDeep",
"moduleSystem": "es6",
"valid": true
},
{
"resolved": "test/extract/fixtures/maxDepth/twoDeep.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./twoDeep",
"moduleSystem": "es6",
"valid": true
}
]
},
{
"source": "test/extract/fixtures/maxDepth/twoDeep.js",
"dependencies": []
},
{
"source": "test/extract/fixtures/maxDepth/sub/oneDeepInSub.js",
"dependencies": [
{
"resolved": "test/extract/fixtures/maxDepth/sub/twoDeepInSub.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./twoDeepInSub",
"moduleSystem": "es6",
"valid": true
}
]
},
{
"source": "test/extract/fixtures/maxDepth/sub/twoDeepInSub.js",
"dependencies": []
}
],
"summary": {
"violations": [],
"error": 0,
"warn": 0,
"info": 0,
"totalCruised": 7,
"optionsUsed": {
"outputTo": "./test/extract/maxDepth2.json",
"exclude": "",
"maxDepth": 2,
"system": [
"amd",
"cjs",
"es6"
],
"outputType": "json"
}
}
}
Loading

0 comments on commit a31d645

Please sign in to comment.