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(); }); });
.with.property("_metrics") .which.is.an("array") .that.has.lengthOf(mockMetrics.length); expect(value) .to.be.an("object") .with.property("metricA") .with.property("valueA") .that.equals(mockMetrics[index].metricA.valueA); .with.property("metricB") .with.property("valueA") .that.equals(mockMetrics[index].metricB.valueA); .with.property("metricB") .with.property("valueB") .that.equals(mockMetrics[index].metricB.valueB); });
.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)));
log.should.be.instanceof(EventEmitter); log.should.have.property('exitOnError', true); log.transports.should.be.an('object').with.property('console'); log.transports.console.should.be.instanceof(EventEmitter); log.transports.console.should.have.property('level', 'warn'); fs.existsSync('/tmp/logz').should.be.true; _.forEach(['error-file', 'log-file'], transport => { log.transports.should.be.an('object').with.property(transport); log.transports[transport].should.be.instanceof(EventEmitter); log.transports[transport].should.have.property('level', 'warn');
it('should return some nodes', () => { // given const spans = [...trace(edgeSpan(), uiAppSpan(), mergedSpan()), ...trace(uiAppSpan(), meshSpan(), serverSpan(), databaseSpan())]; // when const {nodes} = extractNodesAndLinks({spans, serviceName: 'some-ui-app', traceLimitReached: false}); // then expect(nodes) .to.be.an('array') .with.lengthOf(5); });
it('GET /products should return three products', async function() { const req = { method: 'GET', uri: `${BASEURL}/products`, resolveWithFullResponse: true, json: true } const response = await request(req) expect(response.statusCode).to.equal(200) expect(response.body).to.have.property('data').with.lengthOf(3) })
Object.keys(TEST_INPUTS).forEach((alias) => it(`should render ${alias} as MathML`, async function () { if (TEST_INPUTS[alias].input === 'mathml') { this.timeout(100); this.slow(5); } const event = Object.assign({ output: 'mathml' }, TEST_INPUTS[alias]); const actual = await render(event); expect(actual).to.be.an('object').with.keys('contentType', 'data'); expect(actual.contentType).to.be.a('string').that.equals('application/mathml+xml'); expect(actual.data).to.be.a('string').that.contains('</math>'); }));
Object.keys(TEST_INPUTS).forEach((alias) => it(`should render ${alias} as PNG`, async function () { this.slow(2000); const event = Object.assign({ output: 'png', width: 100 }, TEST_INPUTS[alias]); const actual = await render(event); expect(actual).to.be.an('object').with.keys('contentType', 'isBase64Encoded', 'data'); expect(actual.contentType).to.be.a('string').that.equals('image/png'); expect(actual.isBase64Encoded).to.be.a('boolean').that.equals(true); expect(actual.data).to.be.a('string').that.matches(/^[a-zA-Z0-9+/=]+$/); expect(Buffer.from(actual.data, 'base64').slice(0, PNG_SIGNATURE.byteLength)).to.be.an.instanceOf(Buffer) .that.deep.equals(PNG_SIGNATURE); }));
it('should gracefully handle missing parent spans', () => { // given const spans = trace(uiAppSpan()); spans[0].parentSpanId = randomId(); // missing parent span // when const {summary, nodes, links} = extractNodesAndLinks({spans, serviceName: 'some-ui-app', traceLimitReached: false}); // then expect(summary).to.have.property('hasViolations', false); expect(nodes) .to.be.an('array') .with.lengthOf(1); expect(links).to.be.an('array').that.is.empty; });
it('should return some links', () => { // given const spans = trace(edgeSpan(), gatewaySpan(), uiAppSpan(), serverSpan(), databaseSpan()); // when const {links} = extractNodesAndLinks({spans, serviceName: 'some-ui-app', traceLimitReached: false}); // then expect(links) .to.be.an('array') .with.lengthOf(4); });
it('should add metadata when controller have an action get', () => { const instance = decorators.controller('/my-controller')(MyController, { myMethod: decorators.get() }) expect(instance).to.have.property('$routes').with.lengthOf(1) expect(instance.$routes).to.eql([{ httpMethod: 'get', endpointFn: 'myMethod', actionPath: '/my-controller', actionMiddlewares: [] }]) })