it("should generate a valid date below exclusive 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, exclusiveMaximum: true }); for (let i = 0; i < iterations; i++) { expect(schema.sample()) .to.be.an.instanceOf(Date) .and.beforeTime(max); } });
it("should generate a valid date within exclusive 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, exclusiveMinimum: true, exclusiveMaximum: true }); for (let i = 0; i < iterations; i++) { expect(schema.sample()) .to.be.an.instanceOf(Date) .and.afterTime(min) .and.beforeTime(max); } });
let lastModified = new Date(res.headers["last-modified"]); expect(lastModified).to.be.afterTime(before); expect(lastModified).to.be.beforeTime(new Date()); done(); }));
it("should generate an array of minItems", () => { let min = new Date(1995, 6, 18, 12, 30, 45, 0); let max = new Date(1995, 6, 18, 12, 30, 45, 10); let schema = new JsonSchema({ type: "array", minItems: 25, items: { type: "string", format: "date-time", minimum: min, exclusiveMinimum: true, maximum: max, exclusiveMaximum: true } }); for (let i = 0; i < iterations; i++) { let array = schema.sample(); expect(array).to.be.an("array").with.length.at.least(25); array.forEach((item) => { expect(item).to.be.an.instanceOf(Date).afterTime(min).beforeTime(max); }); } });