@prismicio/mock
Version:
Generate mock Prismic documents, fields, Slices, and models for development and testing environments
19 lines (18 loc) • 656 B
JavaScript
import { createFaker } from "../lib/createFaker.js";
import { select as select$1 } from "../model/select.js";
const select = (config) => {
var _a, _b;
const faker = config.faker || createFaker(config.seed);
const model = config.model || select$1({ faker });
const defaultValue = (_a = model.config) == null ? void 0 : _a.default_value;
const options = ((_b = model.config) == null ? void 0 : _b.options) || [];
if (config.state === "empty") {
return null;
} else {
return typeof defaultValue === "string" && faker.boolean() ? defaultValue : faker.randomElement(options);
}
};
export {
select
};
//# sourceMappingURL=select.js.map