Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
"extends" tests now use code inside this project (#1117)
Browse files Browse the repository at this point in the history
This helps avoid weird dependency bugs that cause builds to fail
  • Loading branch information
jkillian committed Apr 12, 2016
1 parent 4b37269 commit cea5d23
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"grunt-tslint": "latest",
"mocha": "^2.2.5",
"tslint": "latest",
"tslint-config-typings": "0.1.6",
"tslint-config-unional": "0.1.5",
"tslint-test-config": "./test/external/tslint-test-config",
"tslint-test-custom-rules": "./test/external/tslint-test-custom-rules",
"typescript": "latest"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test/config/tslint-extends-package-array.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": [
"tslint-config-unional",
"tslint-test-custom-rules",
"./tslint-custom-rules-with-two-dirs.json"
],
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion test/config/tslint-extends-package-no-mod.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "tslint-config-unional"
"extends": "tslint-test-custom-rules"
}
4 changes: 2 additions & 2 deletions test/config/tslint-extends-package-two-levels.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "tslint-config-typings",
"rulesDirectory": "./rules",
"extends": "tslint-test-config/tslint.json",
"rulesDirectory": "../files/custom-rules",
"rules": {
"always-fail": false
}
Expand Down
5 changes: 3 additions & 2 deletions test/config/tslint-extends-package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "tslint-config-unional",
"extends": "tslint-test-custom-rules",
"rules": {
"always-fail": false
"rule-two": true,
"rule-three": false
}
}
29 changes: 21 additions & 8 deletions test/configurationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ describe("Configuration", () => {
let config = loadConfigurationFromPath("./test/config/tslint-extends-package.json");

assert.isArray(config.rulesDirectory);
assert.isFalse(config.rules["always-fail"]);
assert.isTrue(Object.keys(config.rules).length > 1);
assert.deepEqual(config.rules, {
"rule-one": true,
"rule-two": true,
"rule-three": false,
});
});

it("extends with package without customization", () => {
let config = loadConfigurationFromPath("./test/config/tslint-extends-package-no-mod.json");

assert.isArray(config.rulesDirectory);
assert.isTrue(Object.keys(config.rules).length > 1);
assert.deepEqual(config.rules, {
"rule-one": true,
"rule-two": false,
});
});

it("extends with package two levels (and relative path in rulesDirectory)", () => {
Expand All @@ -84,17 +90,24 @@ describe("Configuration", () => {
assert.lengthOf(config.rulesDirectory, 2);
assert.isTrue(fs.existsSync(config.rulesDirectory[0]));
assert.isTrue(fs.existsSync(config.rulesDirectory[1]));
assert.isFalse(config.rules["always-fail"]);
assert.isTrue(Object.keys(config.rules).length > 1);
assert.deepEqual(config.rules, {
"always-fail": false,
"rule-one": true,
"rule-two": true,
"rule-four": true,
});
});

it("extends with array", () => {
let config = loadConfigurationFromPath("./test/config/tslint-extends-package-array.json");

assert.isArray(config.rulesDirectory);
assert.isTrue(config.rules["no-fail"]);
assert.isFalse(config.rules["always-fail"]);
assert.isTrue(Object.keys(config.rules).length > 1);
assert.deepEqual(config.rules, {
"always-fail": false,
"no-fail": true,
"rule-one": true,
"rule-two": false,
});
});
});
});
File renamed without changes.
6 changes: 6 additions & 0 deletions test/external/tslint-test-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "tslint-test-config",
"version": "0.0.1",
"main": "index.js",
"scripts": {}
}
7 changes: 7 additions & 0 deletions test/external/tslint-test-config/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "tslint-test-custom-rules",
"rules": {
"rule-two": true,
"rule-four": true
}
}
6 changes: 6 additions & 0 deletions test/external/tslint-test-custom-rules/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "tslint-test-custom-rules",
"version": "0.0.1",
"main": "tslint.json",
"scripts": {}
}
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions test/external/tslint-test-custom-rules/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rulesDirectory": ["./rules"],
"rules": {
"rule-one": true,
"rule-two": false
}
}

0 comments on commit cea5d23

Please sign in to comment.