Files
shields/lib/nodeify-sync.spec.js
2017-10-14 15:41:56 -04:00

25 lines
711 B
JavaScript

'use strict';
const assert = require('assert');
const nodeifySync = require('./nodeify-sync');
describe('nodeifySync', function() {
it('Should return the result via the callback', function(done) {
const exampleValue = {};
nodeifySync(() => exampleValue, (err, result) => {
assert.equal(err, undefined);
assert.strictEqual(result, exampleValue);
done();
});
});
it('Should catch an error and return it via the callback', function(done) {
const exampleError = Error('This is my error!');
nodeifySync(() => { throw exampleError; }, (err, result) => {
assert.strictEqual(err, exampleError);
assert.equal(result, undefined);
done();
});
});
});