View | Details | Raw Unified | Return to bug 38503
Collapse All | Expand All

(-)a/t/cypress/integration/t/mockData.ts (+17 lines)
Lines 16-18 describe("Generate Random Patrons", () => { Link Here
16
        });
16
        });
17
    });
17
    });
18
});
18
});
19
20
describe("Generate Random Library", () => {
21
    it("should generate a random library from the schema", () => {
22
        cy.task("buildSampleLibrary").then(mockLibrary => {
23
            expect(mockLibrary).to.have.property("library_id");
24
        });
25
    });
26
});
27
28
describe("Generate Random Libraries", () => {
29
    it("should generate 42 random library from the schema", () => {
30
        cy.task("buildSampleLibraries", 42).then(mockLibraries => {
31
            expect(mockLibraries.length).to.equal(42);
32
            expect(mockLibraries[0]).to.have.property("library_id");
33
        });
34
    });
35
});
(-)a/t/cypress/plugins/index.js (-1 / +8 lines)
Lines 18-29 module.exports = (on, config) => { Link Here
18
    mysql.configurePlugin(on);
18
    mysql.configurePlugin(on);
19
};
19
};
20
20
21
const { buildSamplePatron, buildSamplePatrons } = require("./mockData.js");
21
const {
22
    buildSamplePatron,
23
    buildSamplePatrons,
24
    buildSampleLibrary,
25
    buildSampleLibraries,
26
} = require("./mockData.js");
22
27
23
module.exports = (on, config) => {
28
module.exports = (on, config) => {
24
    on("task", {
29
    on("task", {
25
        buildSamplePatron,
30
        buildSamplePatron,
26
        buildSamplePatrons,
31
        buildSamplePatrons,
32
        buildSampleLibrary,
33
        buildSampleLibraries,
27
    });
34
    });
28
    return config;
35
    return config;
29
};
36
};
(-)a/t/cypress/plugins/mockData.js (-1 / +14 lines)
Lines 38-46 const buildSamplePatron = () => { Link Here
38
    return buildSamplePatrons()[0];
38
    return buildSamplePatrons()[0];
39
};
39
};
40
40
41
const buildSampleLibraries = (count = 1) => {
42
    const yamlPath = "api/v1/swagger/definitions/library.yaml";
43
    const schema = readYamlFile(yamlPath);
44
    return Array.from({ length: count }, () =>
45
        generateDataFromSchema(schema.properties)
46
    );
47
};
48
49
const buildSampleLibrary = () => {
50
    return buildSampleLibraries()[0];
51
};
52
41
module.exports = {
53
module.exports = {
42
    generateMockData,
54
    generateMockData,
43
    generateDataFromSchema,
55
    generateDataFromSchema,
44
    buildSamplePatron,
56
    buildSamplePatron,
45
    buildSamplePatrons,
57
    buildSamplePatrons,
58
    buildSampleLibrary,
59
    buildSampleLibraries,
46
};
60
};
47
- 

Return to bug 38503