Sazerac is a library for data-driven tests, where a series of tests asserts that the return value of a function matches the expected value. It provides nice syntax for tightening this up. https://hackernoon.com/sazerac-data-driven-testing-for-javascript-e3408ac29d8c This converts our tests to use it, and replaces some similar home-grown code. I fixed one bug I encountered along the way: mikec/sazerac#12.
25 lines
713 B
JavaScript
25 lines
713 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();
|
|
});
|
|
});
|
|
});
|