Skip to content

Commit

Permalink
Fix os test output tests
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Jan 30, 2024
1 parent a429641 commit 08fa11f
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions test/test-test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
/* global describe it expect before beforeEach afterEach */
require('mocha');
require('should');
const clc = require('cli-color');
const fs = require('fs');
const _ = require('lodash');
const util = require('util');
const sinon = require('sinon');
const prompt = require('prompt');
const rimraf = require('rimraf');
const process = require('process');
const fsJson = require('fs-json')();
const expect = require('chai').expect;
const bddStdin = require('bdd-stdin');
const proxyquire = require('proxyquire');
const changeCase = require('change-case');

const fakeHelpers = require('./helpers/fakeHelpers');

const {
dummySession,
dummySessions,
dummyTestPass,
dummyTestFail
} = require('./helpers/dummyData');
Expand All @@ -39,15 +31,14 @@ const test = proxyquire('../controller/test', {
});

const projectsDirectory = './test/files/environment/projects';
const projectEntriesPath =
'./test/files/workenvironmentspace/projects/projects.json';

describe('test', function () {
before(function (done) {
rimraf(projectsDirectory, () => done());
});

afterEach(function () {
// @ts-ignore
if (console.log.restore) console.log.restore();
});

Expand Down Expand Up @@ -135,17 +126,29 @@ describe('test', function () {
const log = sinon.spy(console, 'log');
passTests(project).then(function (result) {
const stats = result.testResults.stats;
const { failures, passes, pending, tests } = stats;

expect(
log.calledWith(clc.bgBlack.white(' Total tests: 4 '))
log.calledWith(sinon.match(new RegExp(`Total tests:\\W+${tests}`))),
"should include 'Total' test count"
).to.be.true;
expect(
log.calledWith(clc.bgBlue.white(' Passing tests: 4 '))
log.calledWith(
sinon.match(new RegExp(`Passing tests:\\W+${passes}`))
),
'should include "Passing" test count'
).to.be.true;
expect(
log.calledWith(clc.bgYellow.black(' Pending tests: 0 '))
log.calledWith(
sinon.match(new RegExp(`Pending tests:\\W+${pending}`))
),
'should include "Pending" test count'
).to.be.true;
expect(
log.calledWith(clc.bgRed.white(' Failing tests: 0 '))
log.calledWith(
sinon.match(new RegExp(`Failing tests:\\W+${failures}`))
),
'should include "Failing" test count'
).to.be.true;
done();
});
Expand All @@ -155,17 +158,29 @@ describe('test', function () {
const log = sinon.spy(console, 'log');
failTests(project).then(function (result) {
const stats = result.testResults.stats;
const { failures, passes, pending, tests } = stats;

expect(
log.calledWith(clc.bgBlack.white(' Total tests: 4 '))
log.calledWith(sinon.match(new RegExp(`Total tests:\\W+${tests}`))),
"should include 'Total' test count"
).to.be.true;
expect(
log.calledWith(clc.bgBlue.white(' Passing tests: 0 '))
log.calledWith(
sinon.match(new RegExp(`Passing tests:\\W+${passes}`))
),
'should include "Passing" test count'
).to.be.true;
expect(
log.calledWith(clc.bgYellow.black(' Pending tests: 0 '))
log.calledWith(
sinon.match(new RegExp(`Pending tests:\\W+${pending}`))
),
'should include "Pending" test count'
).to.be.true;
expect(
log.calledWith(clc.bgRed.white(' Failing tests: 4 '))
log.calledWith(
sinon.match(new RegExp(`Failing tests:\\W+${failures}`))
),
'should include "Failing" test count'
).to.be.true;
done();
});
Expand Down

0 comments on commit 08fa11f

Please sign in to comment.