mockMsg.should.eql(msg); should.exist(opts); should.equal(opts.type, 'broadcast'); cb(); let channelRemote = remote(app); channelRemote.broadcast(mockRoute, mockMsg, { type: 'broadcast' }).then(() => { invokeCount.should.equal(1); done(); }); mockMsg.should.eql(msg); should.exist(opts); should.equal(opts.type, 'broadcast'); true.should.equal(opts.userOptions.binded); cb(); userOptions: { binded: true } }).then(() => { invokeCount.should.equal(1); done(); });
it('should have typeFilter value when there is a type filter', function (done) { supertest(schsrch) .get('/search/?query=' + encodeURIComponent('0610_s17_qp_1.pdf')) .expect(200) .expect(res => should.equal(res.body.typeFilter, 'qp')) .end(done) })
describe('getPWMFreq()', () => { const addr = 0x40; const instance = pwm({ i2c, address: addr }).init(); i2c.resetAll(); it('should read prescale val', (done) => { instance.getPWMFreq((err) => { should.equal(err, null); i2c.readByte.should.be.calledWith(addr, 0xFE); done(); }); }); });
describe('softwareReset()', () => { it('should send a software reset (SWRST) command to all servolib drivers on the bus', (done) => { pwm({ i2c }).init().softwareReset((err) => { should.equal(err, null); i2c.sendByte.should.be.calledOnce(); i2c.sendByte.should.be.calledWith(0x00, 0x06); done(); }); }); });
it('should initialize asynchronously with arr', (done) => { (function () { dc({ pwm, pins: [8, 10, 9] }).init((err) => { should.equal(err, null); done(); }); }).should.not.throw(); });
it('should change speed asynchronously', (done) => { const stub = sinon.stub(pwm, 'setPWM').yieldsAsync(null); dc({ pwm, pins: ports.M1 }).init((err, res) => { should.equal(err, null); res.setSpeed(50, (error) => { should.equal(error, null); stub.should.be.calledWith(8, 0, 2040); stub.restore(); done(); }); }); });
it('should respect default speed on asynch init', (done) => { const stub = sinon.stub(pwm, 'setPWM').yieldsAsync(null); dc({ pwm, pins: ports.M1 }).init((err) => { should.equal(err, null); stub.should.be.calledWith(8, 0, 4080); stub.restore(); done(); }); });
it('should initialize asynchronously with obj', (done) => { (function () { dc({ pwm, pins: ports.M1 }).init((err) => { should.equal(err, null); done(); }); }).should.not.throw(); });
it('should run back asynchronously', (done) => { const stub = sinon.stub(pwm, 'setPin').yieldsAsync(null); dc({ pwm, pins: ports.M1 }).init((err, res) => { should.equal(err, null); res.run('back', (error) => { should.equal(error, null); stub.should.be.calledWith(10, 0); stub.should.be.calledWith(9, 1); stub.restore(); done(); }); }); });
it('should initialize asynchronously', (done) => { (function () { stepper({ pwm, pins: ports[0] }).init((err) => { should.equal(err, null); done(); }); }).should.not.throw(); });
mockMsg.should.eql(msg); should.exist(opts); should.equal(opts.type, 'broadcast'); cb(); let channelRemote = remote(app); channelRemote.broadcast(mockRoute, mockMsg, { type: 'broadcast' }).then(() => { invokeCount.should.equal(1); done(); }); mockMsg.should.eql(msg); should.exist(opts); should.equal(opts.type, 'broadcast'); true.should.equal(opts.userOptions.binded); cb(); userOptions: { binded: true } }).then(() => { invokeCount.should.equal(1); done(); });
it('should respect default frequency on asynch init', (done) => { const stub = sinon.stub(pwm, 'setPWMFreq').yieldsAsync(null); dc({ pwm, pins: ports.M1 }).init((err) => { should.equal(err, null); stub.should.be.calledWith(1600); stub.restore(); done(); }); });
it('should have typeFilter value when there is a type filter', function (done) { supertest(schsrch) .get('/search/?query=' + encodeURIComponent('0610 s16 ms')) .expect(200) .expect(res => should.equal(res.body.typeFilter, 'ms')) .end(done) })
it('should return null for typeFilter when there is no type filter', function (done) { supertest(schsrch) .get('/search/?query=' + encodeURIComponent('0610 s17 1')) .expect(200) .expect(res => should.equal(res.body.typeFilter, null)) .end(done) })
it('should run forwards asynchronously', (done) => { const stub = sinon.stub(pwm, 'setPin').yieldsAsync(null); dc({ pwm, pins: ports.M1 }).init((err, res) => { should.equal(err, null); res.run('fwd', (error) => { should.equal(error, null); stub.should.be.calledWith(10, 1); stub.should.be.calledWith(9, 0); stub.restore(); done(); }); }); });