Skip to content

Instantly share code, notes, and snippets.

@AGhost-7
Last active February 20, 2016 13:44
Show Gist options
  • Select an option

  • Save AGhost-7/2c1d3d8d3f232773d6f5 to your computer and use it in GitHub Desktop.

Select an option

Save AGhost-7/2c1d3d8d3f232773d6f5 to your computer and use it in GitHub Desktop.
Proper unit testing in Seneca?
// npm install seneca mocha
// npm run mocha .
var
seneca = require('seneca')(),
assert = require('assert');
// normally this would be a `module.exports = function`...
var myWorkflow = function() {
this.add({
role: 'entity',
cmd: 'save',
base: 'sys',
name: 'case'
}, function (args, done) {
args.ent = {
foo: 'bar'
};
this.prior(args, done);
});
};
describe('some random test', function() {
before(function(done) {
seneca.use(myWorkflow);
seneca.add({
role: 'entity',
cmd: 'save',
base: 'sys',
name: 'case'
}, function(args, done) {
done(null, args);
});
seneca.ready(function() {
done();
});
});
it('should return foo bar', function(done) {
seneca
.make$('sys/case')
.save$(function(err, ent) {
assert.ok(ent.foo === 'bar');
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment