Skip to content

Commit

Permalink
Update tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Jan 28, 2017
1 parent 793a54d commit 2828beb
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 93 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "jasmine",
"test:integration": "npm run pretest && npm run examples:update && jasmine JASMINE_CONFIG_PATH=spec/support/jasmine-integration.json",
"posttest": "npm run lint",
"lint": "tslint -c tslint.json 'src/**/*.ts' && tslint -c tslint.json 'spec/**/*.ts'",
"lint": "tslint -c tslint.json --type-check --project tsconfig.json && tslint -c tslint.json --type-check --project spec/tsconfig.json",
"examples:update": "npm run examples:update:node && npm run examples:update:protractor && npm run examples:update:typescript",
"examples:update:node": "cd examples/node && rm -rf node_modules && npm install",
"examples:update:protractor": "cd examples/protractor && rm -rf node_modules && npm install",
Expand Down Expand Up @@ -54,7 +54,7 @@
"jasmine-core": "2.5.2",
"protractor": "5.0.0",
"remap-istanbul": "0.8.4",
"tslint": "4.3.1",
"tslint": "4.4.2",
"tslint-eslint-rules": "3.2.3",
"typescript": "2.1.5"
}
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/nodeDefineJasmineUnderTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare namespace NodeJS {

function extend(destination, source) {
for (const property in source) {
if ({}.hasOwnProperty.call(source, property)) {
if (source.hasOwnProperty(property)) {
destination[property] = source[property];
}
}
Expand Down
13 changes: 7 additions & 6 deletions spec/helpers/test-helper.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require("colors");

interface String {
stripTime: () => string;
stripTime(): string;
}

// tslint:disable-next-line:no-unbound-method
String.prototype.stripTime = function(): string {
return this.replace(/in (\d+\.?\d*|\.\d+) secs?/, "in {time}") // replace time in summary
.replace(/\((\d+\.?\d*|\.\d+) secs?\)/, "({time})"); // replace time in specs
};

let isArray = (value) => {
return {}.toString.call(value) === "[object Array]";
};
let typeIsArray = Array.isArray || isArray;
let isArray = value => value.toString() === "[object Array]";

let typeIsArray = value => Array.isArray(value) || isArray(value);

let equalOrMatch = (actual, expected) => {
return expected === actual || (expected.test && expected.test(actual));
Expand Down Expand Up @@ -72,7 +72,8 @@ class Test {
this.outputs = [];
this.summary = [];
logInSummary = false;
console.log = (stuff) => {
// tslint:disable-next-line:no-unbound-method
console.log = stuff => {
if (!withColor) {
stuff = stuff.stripColors.stripTime();
}
Expand Down
12 changes: 6 additions & 6 deletions spec/integration/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ const JsDiff = require("diff");
process.env.JASMINE_CONFIG_PATH = "spec/support/jasmine.json";
const TIMEOUT_INCREASED = 120000;

const filter = (diff) => {
const value = (element) => {
const filter = diff => {
const value = element => {
return element.value;
};
const added = diff.filter((element) => {
const added = diff.filter(element => {
return element.added === true;
}).map(value);
const removed = diff.filter((element) => {
const removed = diff.filter(element => {
return element.removed === true;
}).map(value);
return { added, removed };
};

describe("Integration", () => {
it("with jasmine-npm should be ok", (done) => {
it("with jasmine-npm should be ok", done => {
exec("cd examples/node && npm test -s", (error, stdout) => {
const expected = readFileSync("spec/resources/node-example.out", { encoding: "utf-8" });
const { added, removed } = filter(JsDiff.diffLines(expected, stdout));
Expand All @@ -29,7 +29,7 @@ describe("Integration", () => {
});
}, TIMEOUT_INCREASED);

it("with protractor should be ok", (done) => {
it("with protractor should be ok", done => {
exec("cd examples/protractor && npm test -s", (error, stdout) => {
const expected = readFileSync("spec/resources/node-protractor.out", { encoding: "utf-8" });
const { added, removed } = filter(JsDiff.diffLines(expected, stdout));
Expand Down
135 changes: 81 additions & 54 deletions spec/unit/colors-display.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,46 @@ describe("with colors", () => {

describe("when spec", () => {
it("should report success", () => {
const outputs = new Test(this.reporter, function() {
this.describe("suite", () => {
this.it("successful spec", () => {
this.passed();
const outputs = new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.it("successful spec", () => {
this.passed();
});
});
});
}, true).outputs;
},
true).outputs;
expect(outputs).not.contains(" ✓ successful spec");
expect(outputs).contains(" " + "✓ successful spec".green);
});

it("should report failure", () => {
const outputs = new Test(this.reporter, function() {
this.describe("suite", () => {
this.it("failed spec", () => {
this.failed();
const outputs = new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.it("failed spec", () => {
this.failed();
});
});
});
}, true).outputs;
},
true).outputs;
expect(outputs).not.contains(" ✗ failed spec");
expect(outputs).contains(" " + "✗ failed spec".red);
});

it("should not report pending", () => {
const outputs = new Test(this.reporter, function() {
this.describe("suite", () => {
this.xit("pending spec", () => {
this.passed();
const outputs = new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.xit("pending spec", () => {
this.passed();
});
});
});
}, true).outputs;
},
true).outputs;
expect(outputs).not.contains(" * pending spec");
expect(outputs).contains(" " + "* pending spec".yellow);
});
Expand All @@ -63,33 +72,42 @@ describe("with colors", () => {

describe("when spec", () => {
it("should report success", () => {
expect(new Test(this.reporter, function() {
this.describe("suite", () => {
this.it("successful spec", () => {
this.passed();
expect(new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.it("successful spec", () => {
this.passed();
});
});
});
}, true).outputs).contains(" " + "✓ successful spec".magenta);
},
true).outputs).contains(" " + "✓ successful spec".magenta);
});

it("should report failure", () => {
expect(new Test(this.reporter, function() {
this.describe("suite", () => {
this.it("failed spec", () => {
this.failed();
expect(new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.it("failed spec", () => {
this.failed();
});
});
});
}, true).outputs).contains(" " + "✗ failed spec".white);
},
true).outputs).contains(" " + "✗ failed spec".white);
});

it("should not report pending", () => {
expect(new Test(this.reporter, function() {
this.describe("suite", () => {
this.xit("pending spec", () => {
this.passed();
expect(new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.xit("pending spec", () => {
this.passed();
});
});
});
}, true).outputs).contains(" " + "* pending spec".blue);
},
true).outputs).contains(" " + "* pending spec".blue);
});
});
});
Expand All @@ -108,33 +126,42 @@ describe("with colors", () => {

describe("when spec", () => {
it("should report success", () => {
expect(new Test(this.reporter, function() {
this.describe("suite", () => {
this.it("successful spec", () => {
this.passed();
expect(new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.it("successful spec", () => {
this.passed();
});
});
});
}, true).outputs).contains(" ✓ successful spec");
},
true).outputs).contains(" ✓ successful spec");
});

it("should report failure", () => {
expect(new Test(this.reporter, function() {
this.describe("suite", () => {
this.it("failed spec", () => {
this.failed();
expect(new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.it("failed spec", () => {
this.failed();
});
});
});
}, true).outputs).contains(" ✗ failed spec");
},
true).outputs).contains(" ✗ failed spec");
});

it("should not report pending", () => {
expect(new Test(this.reporter, function() {
this.describe("suite", () => {
this.xit("pending spec", () => {
this.passed();
expect(new Test(
this.reporter,
function() {
this.describe("suite", () => {
this.xit("pending spec", () => {
this.passed();
});
});
});
}, true).outputs).contains(" * pending spec");
},
true).outputs).contains(" * pending spec");
});
});
});
Expand Down
19 changes: 11 additions & 8 deletions spec/unit/default-display.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,18 @@ describe("with default display", () => {
});

it("should report seed", () => {
expect(new Test(this.reporter, function() {
this.describe("suite 1", () => {
this.it("spec 1", () => {
this.passed();
expect(new Test(
this.reporter,
function() {
this.describe("suite 1", () => {
this.it("spec 1", () => {
this.passed();
});
});
});
}, false, {
random: true
}).summary).contains(/Randomized with seed \d+\./);
},
false,
{ random: true }
).summary).contains(/Randomized with seed \d+\./);
});
});
});
2 changes: 1 addition & 1 deletion spec/unit/display-stacktrace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("With custom stacktrace filter function", () => {
displayStacktrace: true
},
stacktrace: {
filter: (stacktrace) => {
filter: stacktrace => {
return "Updated stacktrace";
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/configuration-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ConfigurationParser {
displaySuccessful: true,
},
stacktrace: {
filter: (stacktrace) => {
filter: stacktrace => {
const lines: string[] = stacktrace.split("\n");
const filtered: string[] = [];
for (let i: number = 1; i < lines.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Configuration {
/**
* Customize stacktrace filtering
*/
filter?: (stacktrace: String) => String;
filter?(stacktrace: String): String;
};
/**
* list of display processor to customize output
Expand Down
Loading

0 comments on commit 2828beb

Please sign in to comment.