describe('parseWebsocketMessage', () => { it('should format websocket message', async () => { const message = parseWebsocketMessage('{"type": "test", "payload": {}}'); expect(message).to.deep.equal({ type: 'test', payload: {}, }); }); });
const compareLuFiles = function(file1, file2) { let result = file1.toString().replace(/\r\n/g, "\n") let fixtureFile = file2.toString().replace(/\r\n/g, "\n") expect(result).to.deep.equal(fixtureFile) }
it("should update series without exceeding limit", () => { options.layoutConfig.view.limit = 3; options.series.high = { highwater: true }; const baseGraph = new BaseLineGraph(options); baseGraph.update({ a: 27, high: 27 }); expect(baseGraph).to.have.nested.property("series.a.y").that.deep.equals([0, 0, 27]); expect(baseGraph).to.have.nested.property("series.high.y").that.deep.equals([27, 27, 27]); });
it('can be trained', () => { const recognizer = createFaceRecognizer() const trainFaces = loadTrainFaces() recognizer.addFaces(trainFaces.sheldon, 'sheldon') recognizer.addFaces(trainFaces.raj, 'raj') const modelState = recognizer.getDescriptorState() expect(modelState).to.be.an('array').lengthOf(2) expect(modelState).to.deep.have.members([ { className: 'sheldon', numFaces: 2 }, { className: 'raj', numFaces: 2 } ]) })
_.each(metricsProvider._aggregation, (value, key) => { expect(key) .to.be.a("string") .that.equals(AGGREGATE_TIME_LEVELS[index++]); expect(value) .to.be.an("object") .that.deep.equals({ data: [], lastTimeIndex: undefined, lastAggregateIndex: 0, scrollOffset: 0 }); });
describe('actions', () => { it('increment should create increment action', () => { expect(actions.increment()).to.deep.equal({ type: actions.INCREMENT_COUNTER }) }) it('decrement should create decrement action', () => { expect(actions.decrement()).to.deep.equal({ type: actions.DECREMENT_COUNTER }) }) it('undo should create undo action', () => { expect(actions.undo()).to.deep.equal({ type: actions.UNDO_COUNTER }) }) it('redo should create redo action', () => { expect(actions.redo()).to.deep.equal({ type: actions.REDO_COUNTER }) }) })
describe('DELETE /api/v1/dashboard/:dashboard_selector', () => { it('should patch dashboard', async () => { await authenticatedRequest .delete('/api/v1/dashboard/test-dashboard') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.deep.equal({ success: true, }); }); }); });
/* eslint-disable no-magic-numbers */ it("should update series and label", () => { options.layoutConfig.view.limit = 4; options.layoutConfig.view.title = "cpu"; options.unit = "%"; const baseGraph = new BaseLineGraph(options); expect(baseGraph).to.have.nested.property("series.a.y").that.deep.equals([0, 0, 0, 0]); baseGraph.update({ a: 29 }); expect(baseGraph).to.have.nested.property("series.a.y").that.deep.equals([0, 0, 0, 29]); expect(baseGraph.node.setLabel).to.have.been.calledWith(" cpu (29%) "); baseGraph.update({ a: 8 }); expect(baseGraph).to.have.nested.property("series.a.y").that.deep.equals([0, 0, 29, 8]); expect(baseGraph.node.setLabel).to.have.been.calledWith(" cpu (8%) "); });
describe('user.getByTelegramUserId', () => { const user = new User(); it('should return user', async () => { const userFound = await user.getByTelegramUserId('555555555'); expect(userFound).to.deep.equal({ id: '0cd30aef-9c4e-4a23-88e3-3547971296e5', language: 'en', }); }); it('should throw notFound error', async () => { const promise = user.getByTelegramUserId('THISDOESNOTEXIST'); return assert.isRejected(promise, 'User with telegram_user_id "THISDOESNOTEXIST" not found'); }); });
describe('#makeArt', () => { it('should be the same as art()', () => { const cli = new Cli(); const func = 'updateAvailable'; const opts = {url: 'https://lando.dev'}; cli.makeArt(func, opts).should.deep.equal(art[func](opts)); }); });
// receiving metrics now would cause an emit sandbox.stub(metricsProvider, "emit").callsFake((key, data, discardEvent) => { if (discardEvent) { return; } expect(key) .to.be.a("string") .that.equals("metrics"); expect(data) .to.be.an("object") .that.deep.equals( _.last(metricsProvider._aggregation[metricsProvider.zoomLevelKey].data) ); });
describe('formatWebsocketMessage', () => { it('should format websocket message', async () => { const message = formatWebsocketMessage('test', {}); expect(message).to.deep.equal( JSON.stringify({ type: 'test', payload: {}, }), ); }); });
describe('hslToRgb', () => { it('should convert hsl to rgb', () => { const rgb = hslToRgb(214, 1, 0.5); expect(rgb).to.deep.equal([0, 110, 255]); }); });
describe('DELETE /api/v1/scene/:scene_selector', () => { it('should delete scene', async () => { await authenticatedRequest .delete('/api/v1/scene/test-scene') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.deep.equal({ success: true, }); }); }); });
it('can be trained with jittering', () => { const recognizer = createFaceRecognizer() const numJitters = 1; const trainFaces = loadTrainFaces() recognizer.addFaces(trainFaces.sheldon, 'sheldon', numJitters) recognizer.addFaces(trainFaces.raj, 'raj', numJitters) const modelState = recognizer.getDescriptorState() expect(modelState).to.be.an('array').lengthOf(2) expect(modelState).to.deep.have.members([ { className: 'sheldon', numFaces: 4 }, { className: 'raj', numFaces: 4 } ]) })