describe('#Landerode', () => { it('should inherit things from Dockerode', () => { expect(Landerode.prototype).to.be.an.instanceOf(Dockerode); }); });
describe("constructor", () => { it("should create a popup screen", () => { const gotoTimeView = new GotoTimeView(options); expect(gotoTimeView).to.be.an.instanceof(GotoTimeView); expect(gotoTimeView).to.have.property("metricsProvider").which.is.an.instanceOf(MetricsProvider); expect(gotoTimeView).to.have.property("screen").which.is.an("object"); expect(gotoTimeView).to.have.property("parent").which.is.an.instanceOf(blessed.box); expect(gotoTimeView).to.have.property("node").which.is.an.instanceOf(blessed.node); expect(gotoTimeView).to.have.property("form").which.is.an.instanceOf(blessed.form); expect(gotoTimeView).to.have.property("timeRangeLabel").which.is.an.instanceOf(blessed.text); expect(gotoTimeView).to.have.property("textBox").which.is.an.instanceOf(blessed.textbox); expect(gotoTimeView).to.have.property("errorText").which.is.an.instanceOf(blessed.text); expect(gotoTimeView).to.have.property("acceptButton").which.is.an.instanceOf(blessed.button); expect(gotoTimeView).to.have.property("cancelButton").which.is.an.instanceOf(blessed.button); }); });
expect(flexsearch_default).to.be.an.instanceOf(FlexSearch); expect(flexsearch_sync).to.be.an.instanceOf(FlexSearch); expect(flexsearch_async).to.be.an.instanceOf(FlexSearch); });
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 throw an error if the value is below the byte minimum", (done) => { let schema = { type: "string", format: "byte" }; let express = helper.parse(schema, "-5", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('"-5" is not a valid byte. Must be between 0 and 255'); })); });
describe("exports.FileDataStore", () => { it('should work with the "new" operator', () => { let dataStore = new swagger.FileDataStore(); expect(dataStore).to.be.an.instanceOf(swagger.DataStore); expect(dataStore).to.be.an.instanceOf(swagger.FileDataStore); }); it('should NOT work without the "new" operator', () => { let dataStore = swagger.FileDataStore(); expect(dataStore).to.equal(undefined); }); });
describe(`exports.Resource (${spec.name})`, () => { it('should work with the "new" operator', () => { let resource = new swagger.Resource("/users", "jdoe", { name: "John Doe" }); expect(resource).to.be.an.instanceOf(swagger.Resource); }); it('should NOT work without the "new" operator', () => { function throws () { swagger.Resource("/users", "jdoe", { name: "John Doe" }); } expect(throws).to.throw(Error); }); });
it("should call the callback if a Swagger object was given", (done) => { let middleware = swagger(spec.samples.petStore, (err, mw) => { if (err) { return done(err); } expect(mw).to.be.an.instanceOf(swagger.Middleware); expect(mw).to.equal(middleware); done(); }); expect(middleware).to.be.an.instanceOf(swagger.Middleware); });
it("should throw an error if the value is not a valid date-time", (done) => { let schema = { type: "string", format: "date-time" }; let express = helper.parse(schema, "2000-11-16T25:75:23Z", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('"2000-11-16T25:75:23Z" is an invalid date-time'); })); });
it("should throw an error if the value is a date", (done) => { let schema = { type: "string", format: "date-time" }; let express = helper.parse(schema, "2015-05-05", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('"2015-05-05" is not a properly-formatted date-time'); })); });
it("should throw an error if the value is not a date", (done) => { let schema = { type: "string", format: "date" }; let express = helper.parse(schema, "hello world", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('"hello world" is not a properly-formatted date'); })); });
it("should throw an error if the value is above the int32 maximum", (done) => { let schema = { type: "integer", format: "int32" }; let express = helper.parse(schema, "2147483648", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('"2147483648" is not a valid int32. Must be between -2147483648 and 2147483647'); })); });
it("should throw an error if required and not specified", (done) => { let schema = { type: "number", required: true }; let express = helper.parse(schema, undefined, done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('Missing required header parameter "Test"'); })); });
it("should throw an error if the value is not a valid date", (done) => { let schema = { type: "string", format: "date" }; let express = helper.parse(schema, "2000-15-92", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain('"2000-15-92" is an invalid date'); })); });
it("should throw an error if the value fails schema validation", (done) => { let schema = { type: "integer", multipleOf: 3 }; let express = helper.parse(schema, "14", done); express.use("/api/test", helper.spy((err, req, res, next) => { expect(err).to.be.an.instanceOf(Error); expect(err.status).to.equal(400); expect(err.message).to.contain("Value 14 is not a multiple of 3"); })); });