_.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('#tryConvertJson', () => { it('should return the unaltered input if input is not a parsable JSON string', () => { const input = 'obiwan'; const result = config.tryConvertJson(input); expect(result).to.be.a('string'); expect(result).to.equal(input); }); it('should return an object if input is a parsable JSON string representing an object', () => { const input = '{}'; const result = config.tryConvertJson(input); expect(result).to.be.an('object'); }); it('should return an array if input is a parsable JSON string representing an array', () => { const input = '[]'; const result = config.tryConvertJson(input); expect(result).to.be.an('array'); }); });
it("should create fullscreen view", () => { const layouts = createPanel([{ views: [ { type: "memory" } ] }]); expect(layouts.views[0]).to.have.property("getPosition").that.is.a("function"); expect(layouts.views[0].getPosition(parent)).to.be.deep.equal({ left: 0, top: 0, width: parent.width, height: parent.height }); });
describe('#installerPkgTask', () => { it('should return scripts/build-darwin.sh on darwin', () => { setPlatform('darwin'); const command = util.installerPkgTask(); command.should.equal('scripts/build-darwin.sh'); resetPlatform(); }); it('should return scripts/build-linux.sh on linux', () => { setPlatform('linux'); const command = util.installerPkgTask(); command.should.be.a('string'); command.should.equal('scripts/build-linux.sh'); resetPlatform(); }); it('should return a PS command that runs scripts\\build-win32.ps1 on windoze', () => { setPlatform('win32'); const command = util.installerPkgTask(); command.should.be.a('string'); _.includes(command, 'scripts\\build-win32.ps1').should.be.true; resetPlatform(); }); });
describe("initialization", () => { it("should use environment variables for configuration", (done) => { const checkMetrics = function (metrics) { expect(metrics).to.be.an("object"); expect(metrics.eventLoop.delay).to.be.a("number"); }; server.on("connection", (socket) => { try { expect(socket).to.be.an("object"); socket.on("error", done); } catch (err) { done(err); } socket.on("metrics", (data) => { tryCatch(done, () => { socket.removeAllListeners("metrics"); checkMetrics(JSON.parse(data)); }); }); }); }); });
expect(state1).to.be.an('array').lengthOf(2) state1.forEach((descs) => { expect(descs.className).to.be.a('string') expect(descs.faceDescriptors).to.be.an('array').lengthOf(2) descs.faceDescriptors.forEach(fd => expect(fd).to.be.an('array').lengthOf(128))
describe("startGraphs", () => { it("offsets at the end or the beginning of the data set", () => { // load some data fill(100, 500); sandbox.stub(metricsProvider, "adjustScrollOffset").callsFake((direction) => { let length = metricsProvider._aggregation[AGGREGATE_TIME_LEVELS[0]].data.length; length = direction < 0 ? -length : Number(length); expect(direction) .to.be.a("number") .that.equals(length); }); metricsProvider.startGraphs(-1); metricsProvider.startGraphs(+1); }); });
describe("resetGraphs", () => { it("resets zoom level and scroll offsets", () => { sandbox.stub(metricsProvider, "setZoomLevel").callsFake((zoom) => { expect(zoom) .to.be.a("number") .that.equals(0); }); _.each(AGGREGATE_TIME_LEVELS, (level) => { expect(metricsProvider) .to.be.an("object") .with.property("_aggregation") .which.is.an("object") .with.property(level) .which.is.an("object") .with.property("scrollOffset") .which.is.a("number") .that.equals(0); }); metricsProvider.resetGraphs(); }); });
it("should provide basic metrics", (done) => { const checkMetrics = function (metrics) { expect(metrics).to.be.an("object"); expect(metrics.eventLoop.delay).to.be.a("number"); expect(metrics.eventLoop.high).to.be.a("number"); expect(metrics.mem.systemTotal).to.equal(20); expect(metrics.mem.rss).to.equal(30); expect(callback).to.be.a("function");
.with.property("metricA") .with.property("valueA") .which.is.a("number") .that.equals(Number(averageA.valueA.toFixed(1))); .with.property("metricB") .with.property("valueA") .which.is.a("number") .that.equals(Number(averageB.valueA.toFixed(1))); .with.property("metricB") .with.property("valueB") .which.is.a("number") .that.equals(Number(averageB.valueB.toFixed(1))); });
const uid = user.getUid(); expect(uid).to.equal('1000'); expect(uid).to.be.a('string'); expect(isFinite(uid)).to.equal(true); resetPlatform(); expect(uid).to.be.a('string'); expect(isFinite(uid)).to.equal(true); }); expect(uid).to.be.a('string'); }); }); const gid = user.getGid(); expect(gid).to.equal('1000'); expect(gid).to.be.a('string'); expect(isFinite(gid)).to.equal(true); resetPlatform(); expect(gid).to.be.a('string'); expect(isFinite(gid)).to.equal(true); }); expect(gid).to.be.a('string'); }); }); it('should return a string', () => {
.to.be.a("string") .that.equals(label); });
// 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) ); });
it('should return a new accessToken when refreshToken and email match', async () => { await RefreshToken.create(refreshToken); return request(app) .post('/v1/auth/refresh-token') .send({ email: dbUser.email, refreshToken: refreshToken.token }) .expect(httpStatus.OK) .then((res) => { expect(res.body).to.have.a.property('accessToken'); expect(res.body).to.have.a.property('refreshToken'); expect(res.body).to.have.a.property('expiresIn'); }); });