-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
22 lines (22 loc) · 966 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { expect, describe, beforeAll, it } = require("@jest/globals");
const generateTemplateFromSchema = require("./index");
const fs = require("fs");
describe("Generate template from schema", () => {
let parsed;
let template;
beforeAll(() => {
parsed = JSON.parse(fs.readFileSync("./index.schema.json").toString());
template = generateTemplateFromSchema(parsed);
});
it("should assert that default properties and required length are the same", () => {
expect(template).toHaveProperty("person");
expect(Object.keys(template).length).toBe(parsed.required.length);
});
it("should assert that default boolean values are either as specified in schema or false", () => {
expect(template.person.hasBeard).toBe(false);
expect(template.person.isNice).toBe(true);
});
it("should assert that the person's hobbies are sports only", () => {
expect(template.person.hobbies).toStrictEqual(["sports"]);
});
});