Skip to content

Commit 92e0e88

Browse files
committed
feature: Combined backend and frontend tests
1 parent 9011c5a commit 92e0e88

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ lint: .FORCE
4343
eslint debug.js
4444

4545
test: .FORCE
46-
mocha test/server/**.js
46+
mocha test/**.js
4747
karma start --single-run
4848

4949
.PHONY: all install clean distclean

karma.conf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ module.exports = function(config) {
1010

1111
// frameworks to use
1212
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13-
frameworks: ['mocha', 'chai'],
13+
frameworks: ['mocha', 'chai', 'sinon'],
1414

1515

1616
// list of files / patterns to load in the browser
1717
files: [
1818
'dist/debug.js',
19-
'test/client/*spec.js'
19+
'test/*spec.js'
2020
],
2121

2222

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"karma-chai": "^0.1.0",
3131
"karma-mocha": "^1.3.0",
3232
"karma-phantomjs-launcher": "^1.0.2",
33+
"karma-sinon": "^1.0.5",
3334
"mocha": "^3.2.0",
3435
"sinon": "^1.17.6",
3536
"sinon-chai": "^2.8.0"

test/client/debug_spec.js

-9
This file was deleted.

test/debug_spec.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* global describe, it */
2+
3+
if (typeof module !== 'undefined' && module.exports) {
4+
const chai = require('chai');
5+
const expect = chai.expect;
6+
7+
const debug = require('../src/index');
8+
const sinon = require('sinon');
9+
var sinonChai = require("sinon-chai");
10+
chai.use(sinonChai);
11+
}
12+
13+
const dummyConsole = {
14+
log: function() {
15+
//dummy function
16+
}
17+
};
18+
19+
debug.log = dummyConsole;
20+
21+
22+
describe('debug', function () {
23+
const log = debug('test');
24+
log.log = sinon.stub();
25+
it('passes a basic sanity check', function () {
26+
expect(log('hello world')).to.not.throw;
27+
});
28+
29+
it('Should output to the log function', function () {
30+
sinon.spy(dummyConsole, 'log');
31+
log('Hello world');
32+
//expect(dummyConsole.log).to.have.been.called;
33+
});
34+
});

test/server/debug_spec.js

-12
This file was deleted.

0 commit comments

Comments
 (0)