spserver/test/base.test.js

36 lines
1 KiB
JavaScript
Raw Normal View History

2015-02-02 15:41:06 +00:00
'use strict';
var fs = require('fs');
var assert = require('assert');
var sinon = require('sinon');
2016-12-15 22:43:52 +00:00
describe('spserver', function () {
2015-02-02 15:41:06 +00:00
var spserver = require('../lib/spserver');
2016-12-15 22:43:52 +00:00
describe('#generateBase()', function () {
it('should return null when file is empty', function () {
2015-02-02 15:41:06 +00:00
assert.strictEqual(null, spserver.generateBase());
assert.strictEqual(null, spserver.generateBase(null, {}));
assert.strictEqual(null, spserver.generateBase(''));
assert.strictEqual(null, spserver.generateBase('', {}));
});
2016-12-15 22:43:52 +00:00
it('should read file contents if string', function () {
2015-02-02 15:41:06 +00:00
var stub = sinon.stub(fs, 'readFileSync').returns('bla');
spserver.generateBase('asdf', {});
assert(stub.called);
stub.restore();
});
2016-12-15 22:43:52 +00:00
it('should return function if file is javascript', function () {
2015-02-04 08:33:17 +00:00
var path = require('path');
2015-02-02 15:41:06 +00:00
var nothing = require('./nothing');
2015-02-04 08:33:17 +00:00
var test = spserver.generateBase(path.resolve('test/nothing.js'), {});
2015-02-02 15:41:06 +00:00
assert.strictEqual(nothing.toString(), test.toString());
});
});
});