describe('#invokeCallback', function () { it('should invoke the function with the parameters', function () { let p1 = 1, p2 = 'str'; let func = function (arg1: number, arg2: string) { p1.should.equal(arg1); p2.should.equal(arg2); }; utils.invokeCallback(func, p1, p2); }); it('should ok if cb is null', function () { let p1 = 1, p2 = 'str'; (function () { utils.invokeCallback(null, p1, p2); }).should.not.throw(); }); });
describe('no-op server events', function() { tests.forEach(function(test) { it(`treat "${test}" as a no-op`, function() { var stopTest = function() { 'Should not call this'.should.not.be.ok(); }; var client = new tmi.client({ logger: { trace: stopTest, debug: stopTest, info: stopTest, warn: stopTest, error: stopTest, fatal: stopTest } }); client._onMessage({data: test}); }); }); });
masterHandler: function(agent, msg, cb) { true.should.not.be.ok(); monitorHandler: function(agent, msg, cb) { true.should.not.be.ok(); }, function(err) { should.not.exist(err); masterConsole.disable(moduleId); monitorConsole.start(this); }, function(err) { should.not.exist(err); monitorConsole.disable(moduleId); monitorConsole.agent.notify(moduleId, orgMsg);
it('should load config from config file absolute path', () => { const confFile = getAssetPath('conf.json'); const conf = require(confFile); const result = runCli(['--config', confFile, '-l', 'debug']); result.stdout.should.be.ok(); result.stderr.should.not.be.ok(); const confLog = JSON.parse(result.stdout.split('\n')[1]); confLog.config.should.be.eql(conf); });
it('should initialize synchronously', () => { (function () { stepper({ pwm, pins: ports[0] }).init(); }).should.not.throw(); });
it('should pass since all requirements meet',function (done) { var stub = sinon.stub(dbus, 'createClient').callsFake(fakeCreateClient); function restore() { stub.restore(); done(); } client = new ThingAccessClient(config, callbacks); client.registerAndOnline() .should.not.be.rejected().then(restore, restore); });
it('should move property claims from one property to another', async () => { const { id } = await createItem() const { guid, property: currentPropertyId } = await addClaim({ id, datatype: 'string', value: randomString() }) const { id: otherStringPropertyId } = await getProperty({ datatype: 'string', reserved: true }) const propertyClaimsId = `${id}#${currentPropertyId}` const res = await movePropertyClaims({ propertyClaimsId, id, property: otherStringPropertyId }) const { entity } = res[0] entity.id.should.equal(id) should(entity.claims[currentPropertyId]).not.be.ok() const movedClaim = entity.claims[otherStringPropertyId][0] movedClaim.id.should.not.equal(guid) })
it('cloning schema with cloneSchema option', () => { const schema = { $schema: 'http://json-schema.org/draft-04/schema#', type: ['string', 'null'], }; const result = convert(schema, { cloneSchema: true }); const expected = { type: 'string', nullable: true, }; should(result).deepEqual(expected, 'result does not match the expected'); should(result).not.deepEqual(schema, 'the schema was modified in place'); });
it('should fail if config does not exist', () => { const confFile = getAssetPath('no-file.json'); const result = runCli(['--config', confFile, '-l', 'error']); result.stdout.should.not.be.ok(); result.stderr.should.be.ok(); result.stderr.should.match(new RegExp(`Could not find file ${confFile}`)); });
it('should initialize asynchronously', (done) => { (function () { stepper({ pwm, pins: ports[0] }).init((err) => { should.equal(err, null); done(); }); }).should.not.throw(); });
it('should fail if config is missing buckets', () => { const confFile = getAssetPath('conf-missing-buckets.json'); const result = runCli(['--config', confFile, '-l', 'error']); result.stdout.should.not.be.ok(); result.stderr.should.be.ok(); result.stderr.should.match(/Bucket list is empty/); });
describe('#invokeCallback', function () { it('should invoke the function with the parameters', function () { let p1 = 1, p2 = 'str'; let func = function (arg1: number, arg2: string) { p1.should.equal(arg1); p2.should.equal(arg2); }; utils.invokeCallback(func, p1, p2); }); it('should ok if cb is null', function () { let p1 = 1, p2 = 'str'; (function () { utils.invokeCallback(null, p1, p2); }).should.not.throw(); }); });
masterHandler: function(agent, msg, cb) { true.should.not.be.ok(); monitorHandler: function(agent, msg, cb) { true.should.not.be.ok(); }, function(err) { should.not.exist(err); masterConsole.disable(moduleId); monitorConsole.start(this); }, function(err) { should.not.exist(err); monitorConsole.disable(moduleId); monitorConsole.agent.notify(moduleId, orgMsg);