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

Commit

Permalink
Added tests for wildcard --test (#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg authored and nchen63 committed Jan 22, 2017
1 parent 23a1565 commit 13ab8ee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/executable/executableTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ describe("Executable", function(this: Mocha.ISuiteCallbackContext) {
});
});

it("exits with code 0 if `--test` flag is used with a wildcard", (done) => {
execCli(["--test", "test/rules/no-e*"], (err) => {
assert.isNull(err, "process should exit without an error");
done();
});
});

it("exits with code 1 if `--test` flag is used with incorrect rule", (done) => {
execCli(["--test", "test/files/incorrect-rule-test"], (err) => {
assert.isNotNull(err, "process should exit with error");
Expand All @@ -167,6 +174,14 @@ describe("Executable", function(this: Mocha.ISuiteCallbackContext) {
});
});

it("exits with code 1 if `--test` flag is used with incorrect rule in a wildcard", (done) => {
execCli(["--test", "test/files/incorrect-rule-*"], (err) => {
assert.isNotNull(err, "process should exit with error");
assert.strictEqual(err.code, 1, "error code should be 1");
done();
});
});

it("exits with code 0 if `--test` flag is used with custom rule", (done) => {
execCli(["--test", "test/files/custom-rule-rule-test"], (err) => {
assert.isNull(err, "process should exit without an error");
Expand Down
10 changes: 10 additions & 0 deletions test/files/incorrect-rule-test-copy/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var testVariable = "eval";

function a() {
function b() {
function c() {
eval("console.log('hi');");
~~~~~~~ [wrong error location and message]
}
}
}
5 changes: 5 additions & 0 deletions test/files/incorrect-rule-test-copy/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-eval": true
}
}

0 comments on commit 13ab8ee

Please sign in to comment.