All files / dist/faker FakerFaker.js

100% Statements 14/14
100% Branches 3/3
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  1x 1x     6x   9x   3x 3x     6x 6x   9x   3x     3x 3x     1x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const faker_1 = require("faker");
class FakerFaker {
    constructor(schema) {
        this.schemaReducer = (schema) => Object.keys(schema).reduce((acc, field) => {
            let generatedFake;
            switch (typeof schema[field]) {
                case "object":
                    generatedFake = this.schemaReducer(schema[field]);
                    break;
                case "string":
                default:
                    generatedFake = (0, faker_1.fake)(schema[field]);
                    break;
            }
            return Object.assign(Object.assign({}, acc), { [field]: generatedFake });
        }, {});
        this.schema = schema;
    }
    Fake() {
        const schema = JSON.parse(this.schema);
        return this.schemaReducer(schema);
    }
}
exports.default = FakerFaker;
//# sourceMappingURL=FakerFaker.js.map