|
|
import expect from 'expect.js';
|
|
|
import muk from 'muk';
|
|
|
import Base from '../../src/lib/directive/base';
|
|
|
import rewire from 'rewire';
|
|
|
describe('base.js', function() {
|
|
|
describe('init', function() {
|
|
|
it();
|
|
|
it('init expect have reproc & proc', function() {
|
|
|
let base = new Base()
|
|
|
expect(base.reproc).to.eql({});
|
|
|
expect(base.proc).to.eql({});
|
|
|
});
|
|
|
});
|
|
|
describe('send', function() {
|
|
|
it();
|
|
|
it('input find expect OK', function(done) {
|
|
|
let base = new Base();
|
|
|
base.reproc.test = function(callback) {
|
|
|
callback('test');
|
|
|
return 'test';
|
|
|
};
|
|
|
let connect = {
|
|
|
send: function(order) {
|
|
|
return order;
|
|
|
},
|
|
|
client: {
|
|
|
remoteAddress: '1.1.1.1'
|
|
|
}
|
|
|
};
|
|
|
base.send(connect, {
|
|
|
input: 'test'
|
|
|
}, function(order) {
|
|
|
expect(order).to.be('test');
|
|
|
done();
|
|
|
})
|
|
|
|
|
|
});
|
|
|
});
|
|
|
describe('receive', function() {
|
|
|
it();
|
|
|
it('input "" expect undefined ', function() {
|
|
|
let base = new Base();
|
|
|
expect(base.receive('', '')).to.be(undefined);
|
|
|
});
|
|
|
|
|
|
it('input [] epxect undefined', function() {
|
|
|
let base = new Base();
|
|
|
expect(base.receive('', [])).to.be(undefined);
|
|
|
});
|
|
|
|
|
|
it('input [111] expect ok', function() {
|
|
|
let base = new Base();
|
|
|
base.proc.test = function() {
|
|
|
return 'test';
|
|
|
}
|
|
|
Base.__set__('locateOrder', function() {
|
|
|
return {
|
|
|
name: 'test'
|
|
|
}
|
|
|
});
|
|
|
Base.__set__('returnProc', function() {
|
|
|
return 'test';
|
|
|
});
|
|
|
Base.__set__('orders', {
|
|
|
'test': {
|
|
|
output: 'test'
|
|
|
}
|
|
|
});
|
|
|
expect(base.receive('', [111])).to.be('test');
|
|
|
});
|
|
|
|
|
|
it('input [111] expect ok', function() {
|
|
|
let base = new Base();
|
|
|
|
|
|
Base.__set__('locateOrder', function() {
|
|
|
return {
|
|
|
name: 'test'
|
|
|
}
|
|
|
});
|
|
|
Base.__set__('returnProc', function() {
|
|
|
return 'test';
|
|
|
});
|
|
|
Base.__set__('orders', {
|
|
|
'test': {
|
|
|
output: 'test'
|
|
|
}
|
|
|
});
|
|
|
expect(base.receive('', [111])).to.be('test');
|
|
|
});
|
|
|
|
|
|
});
|
|
|
describe('procFunc', function() {
|
|
|
it();
|
|
|
it('input "" client test expect test', function() {
|
|
|
let base = new Base();
|
|
|
|
|
|
Base.__set__('returnProc', function() {
|
|
|
return 'test';
|
|
|
});
|
|
|
Base.__set__('orders', {
|
|
|
'test': {
|
|
|
output: 'test'
|
|
|
}
|
|
|
});
|
|
|
expect(base.procFunc('', {
|
|
|
remoteAddress: '1.1.1.1'
|
|
|
}, 'test')).to.be('test');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|