Skip to content

Commit

Permalink
🐛 Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexc155 committed Mar 7, 2020
1 parent 12d3c46 commit aeba0c2
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![License](https://img.shields.io/npm/l/node-template)](https://www.npmjs.com/package/node-template)
[![NPM Downloads](https://img.shields.io/npm/dm/node-template.svg?style=flat-square)](https://www.npmjs.com/package/node-template)
[![Build Status](https://travis-ci.org/alexc155/node-template.svg?branch=master)](https://travis-ci.org/alexc155/node-template)
[![Node.js CI](https://github.com/alexc155/node-template/workflows/Node.js%20CI/badge.svg)](https://github.com/alexc155/node-template/actions?query=workflow%3A%22Node.js+CI%22)
[![Coverage Status](https://coveralls.io/repos/github/alexc155/node-template/badge.svg?branch=master)](https://coveralls.io/github/alexc155/node-template?branch=master)

[![dependencies Status](https://david-dm.org/alexc155/node-template/status.svg)](https://david-dm.org/alexc155/node-template)
Expand Down
12 changes: 6 additions & 6 deletions config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ afterEach(() => {
});

describe('#config', () => {
test('writes a value to the config file', () => {
it('writes a value to the config file', () => {
sut.writeConfig('setting', 'value');
// Run a second time to run thru' if the config file was missing.
sut.writeConfig('setting', 'value');
Expand All @@ -42,15 +42,15 @@ describe('#config', () => {
);
});

test('errors writing an invalid setting to the config file', () => {
it('errors writing an invalid setting to the config file', () => {
const result = sut.writeConfig(undefined, 'value');

expect(result).to.equal(false);

expect(console.error.calledWith('Error in writeConfig: ')).to.equal(true);
});

test('reads a setting from the config file', () => {
it('reads a setting from the config file', () => {
writeFileSync(
CONFIG_FILE,
JSON.stringify({
Expand All @@ -63,7 +63,7 @@ describe('#config', () => {
expect(setting).to.equal('value');
});

test("returns the default value when reading a setting if the setting doesn't exist and there is a default", () => {
it("returns the default value when reading a setting if the setting doesn't exist and there is a default", () => {
writeFileSync(
CONFIG_FILE,
JSON.stringify({
Expand All @@ -76,7 +76,7 @@ describe('#config', () => {
expect(setting).to.equal('/path/to/files');
});

test("errors when reading a setting from the config file if the setting doesn't exist and there is no default", () => {
it("errors when reading a setting from the config file if the setting doesn't exist and there is no default", () => {
writeFileSync(
CONFIG_FILE,
JSON.stringify({
Expand All @@ -91,7 +91,7 @@ describe('#config', () => {
expect(console.error.calledWith('Config setting does not exist')).to.equal(true);
});

test("errors when reading a setting from the config file if the config file doesn't exist", () => {
it("errors when reading a setting from the config file if the config file doesn't exist", () => {
writeFileSync(
CONFIG_FILE,
JSON.stringify({
Expand Down
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"devDependencies": {
"chai": "^4.2.0",
"coveralls": "^3.0.9",
"husky": "^4.2.3",
"jest": "^25.1.0",
"jest-teamcity-reporter": "^0.9.0",
"lint-staged": "^10.0.8",
Expand Down
4 changes: 2 additions & 2 deletions utils/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const sinon = require('sinon');
const sut = require('./');

describe('#utils', () => {
test('logs info messages', () => {
it('logs info messages', () => {
var consoleLog = console.log;
console.log = () => {};
sinon.spy(console, 'log');
Expand All @@ -16,7 +16,7 @@ describe('#utils', () => {
console.log = consoleLog;
});

test('logs error messages', () => {
it('logs error messages', () => {
var consoleError = console.error;
console.error = () => {};
sinon.spy(console, 'error');
Expand Down

0 comments on commit aeba0c2

Please sign in to comment.