From 13ab8ee410c8d9f436cfc67fdc04d1d63bc4c006 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 21 Jan 2017 21:50:53 -0800 Subject: [PATCH] Added tests for wildcard --test (#2096) --- test/executable/executableTests.ts | 15 +++++++++++++++ test/files/incorrect-rule-test-copy/test.ts.lint | 10 ++++++++++ test/files/incorrect-rule-test-copy/tslint.json | 5 +++++ 3 files changed, 30 insertions(+) create mode 100644 test/files/incorrect-rule-test-copy/test.ts.lint create mode 100644 test/files/incorrect-rule-test-copy/tslint.json diff --git a/test/executable/executableTests.ts b/test/executable/executableTests.ts index a28cffe3832..346ea297db6 100644 --- a/test/executable/executableTests.ts +++ b/test/executable/executableTests.ts @@ -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"); @@ -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"); diff --git a/test/files/incorrect-rule-test-copy/test.ts.lint b/test/files/incorrect-rule-test-copy/test.ts.lint new file mode 100644 index 00000000000..b11b3ed8e9e --- /dev/null +++ b/test/files/incorrect-rule-test-copy/test.ts.lint @@ -0,0 +1,10 @@ +var testVariable = "eval"; + +function a() { + function b() { + function c() { + eval("console.log('hi');"); + ~~~~~~~ [wrong error location and message] + } + } +} diff --git a/test/files/incorrect-rule-test-copy/tslint.json b/test/files/incorrect-rule-test-copy/tslint.json new file mode 100644 index 00000000000..1f0ba96f559 --- /dev/null +++ b/test/files/incorrect-rule-test-copy/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-eval": true + } +}