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

(-)a/t/cypress/integration/t/mockData.ts (+9 lines)
Lines 7-9 describe("Generate Random Patron", () => { Link Here
7
        });
7
        });
8
    });
8
    });
9
});
9
});
10
11
describe("Generate Random Patrons", () => {
12
    it("should generate 42 random patron from the schema", () => {
13
        cy.task("buildSamplePatrons", 42).then(mockPatrons => {
14
            expect(mockPatrons.length).to.equal(42);
15
            expect(mockPatrons[0]).to.have.property("patron_id");
16
        });
17
    });
18
});
(-)a/t/cypress/plugins/index.js (-1 / +2 lines)
Lines 18-28 module.exports = (on, config) => { Link Here
18
    mysql.configurePlugin(on);
18
    mysql.configurePlugin(on);
19
};
19
};
20
20
21
const { buildSamplePatron } = require("./mockData.js");
21
const { buildSamplePatron, buildSamplePatrons } = require("./mockData.js");
22
22
23
module.exports = (on, config) => {
23
module.exports = (on, config) => {
24
    on("task", {
24
    on("task", {
25
        buildSamplePatron,
25
        buildSamplePatron,
26
        buildSamplePatrons,
26
    });
27
    });
27
    return config;
28
    return config;
28
};
29
};
(-)a/t/cypress/plugins/mockData.js (-3 / +9 lines)
Lines 26-39 const generateDataFromSchema = properties => { Link Here
26
    return mockData;
26
    return mockData;
27
};
27
};
28
28
29
const buildSamplePatron = () => {
29
const buildSamplePatrons = (count = 1) => {
30
    const yamlPath = "api/v1/swagger/definitions/patron.yaml";
30
    const yamlPath = "api/v1/swagger/definitions/patron.yaml";
31
    const schema = readYamlFile(yamlPath);
31
    const schema = readYamlFile(yamlPath);
32
    return generateDataFromSchema(schema.properties);
32
    return Array.from({ length: count }, () =>
33
        generateDataFromSchema(schema.properties)
34
    );
35
};
36
37
const buildSamplePatron = () => {
38
    return buildSamplePatrons()[0];
33
};
39
};
34
40
35
module.exports = {
41
module.exports = {
36
    generateMockData,
42
    generateMockData,
37
    generateDataFromSchema,
43
    generateDataFromSchema,
38
    buildSamplePatron,
44
    buildSamplePatron,
45
    buildSamplePatrons,
39
};
46
};
40
- 

Return to bug 38503