Bug 38503: Same for libraries
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 7b3426928f)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
6b3711d2c0
commit
7bad7ea76d
|
|
@ -16,3 +16,20 @@ describe("Generate Random Patrons", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Generate Random Library", () => {
|
||||
it("should generate a random library from the schema", () => {
|
||||
cy.task("buildSampleLibrary").then(mockLibrary => {
|
||||
expect(mockLibrary).to.have.property("library_id");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Generate Random Libraries", () => {
|
||||
it("should generate 42 random library from the schema", () => {
|
||||
cy.task("buildSampleLibraries", 42).then(mockLibraries => {
|
||||
expect(mockLibraries.length).to.equal(42);
|
||||
expect(mockLibraries[0]).to.have.property("library_id");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,12 +18,19 @@ module.exports = (on, config) => {
|
|||
mysql.configurePlugin(on);
|
||||
};
|
||||
|
||||
const { buildSamplePatron, buildSamplePatrons } = require("./mockData.js");
|
||||
const {
|
||||
buildSamplePatron,
|
||||
buildSamplePatrons,
|
||||
buildSampleLibrary,
|
||||
buildSampleLibraries,
|
||||
} = require("./mockData.js");
|
||||
|
||||
module.exports = (on, config) => {
|
||||
on("task", {
|
||||
buildSamplePatron,
|
||||
buildSamplePatrons,
|
||||
buildSampleLibrary,
|
||||
buildSampleLibraries,
|
||||
});
|
||||
return config;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,9 +38,23 @@ const buildSamplePatron = () => {
|
|||
return buildSamplePatrons()[0];
|
||||
};
|
||||
|
||||
const buildSampleLibraries = (count = 1) => {
|
||||
const yamlPath = "api/v1/swagger/definitions/library.yaml";
|
||||
const schema = readYamlFile(yamlPath);
|
||||
return Array.from({ length: count }, () =>
|
||||
generateDataFromSchema(schema.properties)
|
||||
);
|
||||
};
|
||||
|
||||
const buildSampleLibrary = () => {
|
||||
return buildSampleLibraries()[0];
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
generateMockData,
|
||||
generateDataFromSchema,
|
||||
buildSamplePatron,
|
||||
buildSamplePatrons,
|
||||
buildSampleLibrary,
|
||||
buildSampleLibraries,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue