Last active
February 20, 2016 13:44
-
-
Save AGhost-7/2c1d3d8d3f232773d6f5 to your computer and use it in GitHub Desktop.
Proper unit testing in Seneca?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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