diff --git a/package.json b/package.json index dac0ce5a..64ad2e66 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,10 @@ "jest": { "coverageThreshold": { "global": { - "branches": 71, - "functions": 86, - "lines": 84, - "statements": 85 + "branches": 73, + "functions": 89, + "lines": 88, + "statements": 88 } }, @@ -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", diff --git a/test/unit/printer.test.ts b/test/unit/printer.test.ts new file mode 100644 index 00000000..5474914b --- /dev/null +++ b/test/unit/printer.test.ts @@ -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); +});