const minTime = ((opts.max * (opts.max + 1)) / 2) * opts.backoff; counter.should.equal(opts.max); timer.should.be.at.least(minTime); clock.restore(); };
Cypress.Commands.add('isNotInViewport', element => { cy.get(element).then($el => { // we won't have horizontal scollbar const rect = $el[0].getBoundingClientRect(); if (rect.top < 0) { expect(rect.bottom).to.be.lessThan(0); } else { expect(rect.top).to.be.at.least(0); } }); });
expect(() => { expect(now).to.be.at.most(oneSecondBefore, "blah"); }).to.throw( AssertionError, "blah: expected " + nowUTC + " to be at most " + beforeUTC );
it("[XNOR] Network.train()", function() { const network = new Network(2,1); const initial = network.test(data.XNOR); network.train(data.XNOR); const final = network.test(data.XNOR); expect(final.error).to.be.at.most(initial.error); });
it("[NOT] Neat.evolve()", async function() { const population = new Neat(1,1, data.NOT); const initial = await population.evaluate(data.NOT); await population.evolve(data.NOT) const final = await population.evolve(data.NOT); // console.log(`Initial Score: ${initial.score}`); // console.log(`Final Score: ${final.score}`); expect(final[0].score).to.be.at.least(initial.score); });
describe('Summoner (integration)', function() { it('should work', async function() { const s = await kayn.Summoner.by.name('Contractz') expect(s.id).to.equal(summoner.id) expect(s.accountId).to.equal(summoner.accountId) expect(s.summonerLevel).to.be.at.least(summoner.summonerLevel) }) })
it("should generate a valid date within min/max", () => { let min = new Date(2008, 5, 27, 15, 32, 17, 100); let max = new Date(2008, 5, 27, 15, 32, 17, 200); let schema = new JsonSchema({ type: "string", format: "date-time", minimum: min, maximum: max }); for (let i = 0; i < iterations; i++) { let date = schema.sample(); expect(date).to.be.an.instanceOf(Date); expect(date.valueOf()).to.be.at.least(min.valueOf()); expect(date.valueOf()).to.be.at.most(max.valueOf()); } });
expect(() => { expect("foo", "blah").to.have.length.of.at.least(4); }).to.throw( AssertionError, "blah: expected 'foo' to have a length at least 4 but got 3" );
describe('GET /api/delegates/count', function () { it('should be ok', function (done) { node.get('/api/delegates/count', function (err, res) { node.expect(res.body).to.have.property('success').to.be.ok; node.expect(res.body).to.have.property('count').to.be.at.least(51); done(); }); }); });
it("should generate a valid date below maximum", () => { let max = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, 10)); let schema = new JsonSchema({ type: "string", format: "date-time", maximum: max }); for (let i = 0; i < iterations; i++) { let date = schema.sample(); expect(date).to.be.an.instanceOf(Date); expect(date.valueOf()).to.be.at.most(max.valueOf()); } });
it("should generate a valid date above minimum", () => { let min = new Date(); min.setUTCMilliseconds(0); let schema = new JsonSchema({ type: "string", format: "date-time", minimum: min }); for (let i = 0; i < iterations; i++) { let date = schema.sample(); expect(date).to.be.an.instanceOf(Date); expect(date.valueOf()).to.be.at.least(min.valueOf()); } });
it("should generate a valid int32", () => { let schema = new JsonSchema({ type: "integer", format: "int32" }); for (let i = 0; i < iterations; i++) { expect(schema.sample()) .to.be.a("number") .and.satisfy(Number.isFinite) .and.satisfy(isWholeNumber) .and.at.least(-2147483648) .and.at.most(2147483647); } });
it("should generate a valid number above minimum", () => { let min = MAX_SAFE_INTEGER - 10; let schema = new JsonSchema({ type: "integer", minimum: min }); for (let i = 0; i < iterations; i++) { expect(schema.sample()) .to.be.a("number") .and.satisfy(Number.isFinite) .and.satisfy(isWholeNumber) .and.at.least(min) .and.at.most(MAX_SAFE_INTEGER); } });