1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var InvocationPerformer = require('../lib/invocation_performer.js'),
|
7 | InvocationLoader = require('../lib/invocation_loader'),
|
8 | InvocationContext = require('../lib/invocation_context'),
|
9 | injectmock = require('injectmock');
|
10 |
|
11 | exports.tearDown = function (done) {
|
12 | injectmock.restoreAll();
|
13 | done();
|
14 | };
|
15 |
|
16 | exports['Get ambigously.'] = function (test) {
|
17 | var performer = new InvocationPerformer();
|
18 | test.equal(performer._getAmbiguously({"foo": "bar"}, "o|f|foo"), "bar");
|
19 | test.equal(performer._getAmbiguously({"foo": "bar"}, "o|f|oo"), null);
|
20 | test.done();
|
21 | };
|
22 |
|
23 | exports['Task worker performer'] = function (test) {
|
24 | var performer = new InvocationPerformer();
|
25 | test.ok(performer);
|
26 | test.done();
|
27 | };
|
28 |
|
29 | exports['Do perform.'] = function (test) {
|
30 | var performer = new InvocationPerformer({
|
31 | context: new InvocationContext({})
|
32 | });
|
33 | injectmock(InvocationLoader.prototype, 'load', function (name, callback) {
|
34 | callback(null, {
|
35 | apply: function (ctx, args) {
|
36 | var callback = args[args.length - 1];
|
37 | callback(null, {});
|
38 | }
|
39 | });
|
40 | });
|
41 | performer.perform({}, function (err) {
|
42 | test.ifError(err);
|
43 | test.done();
|
44 | });
|
45 | };
|
46 |
|