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

(-)a/t/cypress/integration/t/mockData.ts (+5 lines)
Lines 13-18 describe("Generate Random Patron", () => { Link Here
13
        }).then(mockPatron => {
13
        }).then(mockPatron => {
14
            expect(mockPatron.surname).to.equal("test_surname");
14
            expect(mockPatron.surname).to.equal("test_surname");
15
            expect(mockPatron.overdues_count).to.be.a("number");
15
            expect(mockPatron.overdues_count).to.be.a("number");
16
            expect(mockPatron.date_of_birth).to.match(/^\d{4}-\d{2}-\d{2}$/);
17
            // TODO We are not testing for timezone part
18
            expect(mockPatron.updated_on).to.match(
19
                /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
20
            );
16
        });
21
        });
17
    });
22
    });
18
});
23
});
(-)a/t/cypress/plugins/mockData.js (-2 / +9 lines)
Lines 24-29 const generateMockData = type => { Link Here
24
            return [faker.lorem.word(), faker.lorem.word()];
24
            return [faker.lorem.word(), faker.lorem.word()];
25
        case "number":
25
        case "number":
26
            return faker.number.float();
26
            return faker.number.float();
27
        case "date":
28
            return new Date().toISOString().split("T")[0];
29
        case "date-time":
30
            return new Date().toISOString();
27
        default:
31
        default:
28
            return faker.lorem.word();
32
            return faker.lorem.word();
29
    }
33
    }
Lines 35-41 const generateDataFromSchema = (properties, values = {}) => { Link Here
35
        if (values.hasOwnProperty(key)) {
39
        if (values.hasOwnProperty(key)) {
36
            mockData[key] = values[key];
40
            mockData[key] = values[key];
37
        } else {
41
        } else {
38
            mockData[key] = generateMockData(value.type);
42
            let type =
43
                value?.format == "date" || value?.format == "date-time"
44
                    ? value.format
45
                    : value.type;
46
            mockData[key] = generateMockData(type);
39
        }
47
        }
40
    });
48
    });
41
    return mockData;
49
    return mockData;
42
- 

Return to bug 38503