Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Reynolds committed Feb 12, 2019
1 parent cdae9df commit 9b8d6a1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"jest": {
"coverageThreshold": {
"global": {
"branches": 71,
"functions": 86,
"lines": 84,
"statements": 85
"branches": 73,
"functions": 89,
"lines": 88,
"statements": 88
}

},
Expand Down Expand Up @@ -62,7 +62,7 @@
"build": "tsc",
"start": "./build/build.sh",
"lint": "tslint --fix -c tslint.json -p tsconfig.json",
"test": "jest test --coverage",
"test": "jest test --coverage --silent",
"format": "prettier --write {src,test}/**/*.ts"
},
"version": "0.0.9",
Expand Down
22 changes: 22 additions & 0 deletions test/unit/printer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Printer } from "../../src/printer";
import { NullChecker } from "../../src/checker/nullChecker";
import { Query } from "../../src/reader/query";
import { SimpleFormat } from "../../src/formatter/formats/simple";

test("It gets the queries content when the verbose option is set", () => {
const format = new SimpleFormat();
const checker = new NullChecker();
const query = new Query();
const getContentFn = (Query.prototype.getContent = jest.fn());
const printer = new Printer(1, format);
printer.printCheck(checker, query, "");
expect(getContentFn).toHaveBeenCalledTimes(1);
});

test("It calls console.log if a file is not found", () => {
const console = jest.spyOn(global.console, 'log');
const format = new SimpleFormat();
const printer = new Printer(1, format);
printer.warnAboutFileNotFound('some-file');
expect(console).toHaveBeenCalledTimes(1);
});

0 comments on commit 9b8d6a1

Please sign in to comment.