Authored by Rock Zhang

Merge remote-tracking branch 'origin/master'

... ... @@ -13,6 +13,8 @@ sdk.start({
group: 1,
inventoryTime: 400, //设置盘点时长
power: [15, 0, 0, 0] //功率设置
}, function(connected, data) {
console.log(data);
}, function(err, connected, data) {
if (connected) {
console.log(data);
}
});
\ No newline at end of file
... ...
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
... ...
import expect from 'expect.js';
import muk from 'muk';
import info from '../../src/lib/interface';
import Config from '../../src/lib/directive/config';
describe('config.js', function() {
describe('init', function() {
it();
it('expect prower filter stayTime frequency exits', function() {
let config = new Config();
expect(config.reproc[info.setPower.input]).to.be.eql(config.prePower);
expect(config.reproc[info.setFilter.input]).to.be.eql(config.preFilter);
expect(config.reproc[info.setAntStayTime.input]).to.be.eql(config.preStayTime);
expect(config.reproc[info.setFrequency.input]).to.be.eql(config.preFrequency);
});
});
describe('prePower', function() {
it();
it('input [15, 15, 0, 0] expect F30F0F0000', function() {
let config = new Config();
expect(config.prePower([15, 15, 0, 0])).to.be(info.setPower.input + '0F0F0000');
});
});
describe('preFilter', function() {
it();
it('input {on:"1",rssi:-27.5} epxect F701FEED00',
function() {
let config = new Config();
expect(config.preFilter({
on: '1',
rssi: -27.5
})).to.be(info.setFilter.input + '01FEED00');
});
});
describe('preStayTime', function() {
it();
it('input 100 expect CA00000064', function() {
let config = new Config();
expect(config.preStayTime(100)).to.be(info.setAntStayTime.input + '00000064');
});
});
describe('preFrequency', function() {
it();
it('input 10 expect BF0A000000', function() {
let config = new Config();
expect(config.preFrequency(10)).to.be(info.setFrequency.input + '0A000000')
});
});
});
\ No newline at end of file
... ...