UNPKG

functional-google-cloud

Version:

Google Cloud Utilities functions in Functional Programming Style

34 lines 1.36 kB
import fc from 'fast-check'; import { keys } from 'ramda'; export const nonEmptyString = () => fc.hexaString(1, 128); export const id = () => fc.hexaString(16, 16); export const nonModelObject = () => fc.anything().filter((object) => !object || !object.id); export const modelBase = () => fc.record({ id: id(), }); export const modelData = () => fc.object({ maxDepth: 1, key: fc.hexaString(1, 16), values: [fc.string(), fc.integer()], }); export const model = () => fc .tuple(modelBase(), modelData()) .map(([base, content]) => (Object.assign(Object.assign({}, base), content))); export const modelAndUpdate = () => fc.tuple(model(), model()).map(([model, update]) => [ model, Object.assign(Object.assign({}, update), { id: model.id }), ]); export const operation = () => fc.constantFrom('=='); export const condition = () => fc.tuple(nonEmptyString(), operation(), nonEmptyString()); export const modelAndConditions = () => model() .chain((model) => { const modelKeys = keys(model); return fc.tuple(fc.constant(model), fc.subarray(modelKeys, 1, modelKeys.length)); }) .map(([model, keys]) => [ model, keys.map((key) => [key, '==', model[key]]), ]); export const models = () => fc.array(model(), 2, 16); export const table = () => id(); //# sourceMappingURL=Arbitraries.js.map