Compose is a function that allows you to easily combine multiple HelixSpec Specs and/or regular objects
to create a brand new HelixSpec.
Argument | Type | Description |
---|---|---|
specs |
HelixSpec or object |
HelixSpec classes and/or objects to combine together. |
HelixSpec
: Renders a single HelixSpec class.
import { compose, createSpec, faker } from "@helpscout/helix";
const Dinosaur = createSpec({
id: faker.datatype.number(),
name: faker.name.firstName(),
location: faker.address.country(),
});
const MrDNA = createSpec({
name: "Mr. DNA",
avatar: faker.image.avatar(),
email: faker.internet.email(),
jobTitle: "Guide",
});
const User = createSpec({
uuid: faker.datatype.uuid(),
description: faker.lorem.sentence(),
});
const MrDinosaurUser = compose(Dinosaur, MrDNA, User);
MrDinosaurUser.generate();
// {
// id: 18482,
// name: 'Mr. DNA',
// location: 'Malawi',
// avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/robinclediere/128.jpg',
// email: '[email protected]',
// jobTitle: 'Guide',
// uuid: 'd1b4d842-b970-466e-86d9-d7d1b9b32782',
// description: 'Natus in delectus animi ex sed voluptatum molestias quae.'
// }