Skip to content

Releases: helpscout/helix

Helix - v0.0.7

03 Nov 22:27
Compare
Choose a tag to compare

This update fixes the build files of Helix to include the latest code + the new compose function.

Helix - v0.0.6

03 Nov 18:55
Compare
Choose a tag to compare

Adds faker.computed to generate computed values

This update adds a new method to faker (faker.computed) that allows you to
create custom values based on combining faker methods with other things (like
strings, numbers, or other faker methods)

Example

const props = {
  fname: faker.name.firstName(),
  lname: faker.name.lastName()
}
const value = faker.computed(props)(values => {
  const { fname, lname } = values
  return `${fname} ${lname}`
})

console.log(value())
// Michelle Santos

Seeding

Computed values support seeding! The seed value is passed in when the computed value is instantiated. When generated with HelixSpec.generate, this is done automatically.

const props = {
  fname: faker.name.firstName(),
  lname: faker.name.lastName()
}
const value = faker.computed(props)(values => {
  const { fname, lname } = values
  return `${fname} ${lname}`
})

// Generate the computed value, with a seed value of 23
console.log(value(23))

Note: The API for computed is a little verbose at the moment. @knicklabs and I have discussed ideas on how to make it nicer, but it's not required for now.

This update also refactors some of the functions used in Helix to their own
separate files, as well as adds the appropriate comment docs.

Resolves: #2

Helix - v0.0.5

03 Nov 18:55
Compare
Choose a tag to compare

Add compose function, and HelixSpec.extend

This update adds a new compose function, that allows you to combine
Specs together (as well as regular objects) into a new HelixSpec.

This is powered by the new HelixSpec.extend method, which uses Object.assign
to extend the spec "shape".

The new composed Spec is generated with the usual .generate method.

Example

const PersonSpec = new HelixSpec({
  id: faker.random.number()
})
const MessageSpec = new HelixSpec({
  read: faker.random.boolean(),
  timestamp: faker.date.past(),
  message: faker.lorem.paragraph()
})

const ComposedSpec = compose(PersonSpec, MessageSpec)
const fixture = ComposedSpec.generate()

Resolves: #3

Helix - v0.0.4

03 Nov 14:38
Compare
Choose a tag to compare

Add max count to generate() method

This update adds a max count to the generate method to support the creation of fixtures between 2 sets of numbers.

The following will generate between 4-10 fixtures into an array.

const min = 4
const max = 10

Spec.generate(min, max)

Feature added by @brettjonesdev

Helix - v0.0.3

02 Nov 22:30
Compare
Choose a tag to compare

Nested Specs + Multi-generation

This updates Helix to support nested Specs, as well as the ability to
very easily generate multiple instances of a Spec.

Multi-generation

You can generate multiple instances of your Spec fixture using the generate() method. All you have to do is pass in the number of instances you want generated!

const Text = createSpec({
  id: faker.random.number(),
  message: faker.lorem.paragraph()
})

const fixture = Text.seed(50).generate()

// Output
// [{}, {}, {}, {}, {}]

Seeding

To seed multi-generated fixtures, simply use the .seed() method before generating.

const Text = createSpec({
  id: faker.random.number(),
  message: faker.lorem.paragraph()
})

const fixture = Text.seed(50).generate()

Note: Seed values aren't passed down from the parent Spec to children multi-specs.

Nesting

Specs can be nested! In the example below, you can see that we've created 2 Specs: MessageSpec and ConvoSpec. Our ConvoSpec contains MessageSpec inside.

const MessageSpec = createSpec({
  id: faker.random.number(),
  read: faker.random.boolean(),
  message: faker.lorem.paragraph()
})

const ConvoSpec = createSpec({
  id: faker.random.number(),
  messages: MessageSpec.generate(5)
})

const fixture = ConvoSpec.generate()

// Output
// {
//   id: 12341,
//   messages: [{}, {}, {}, {}, {}]
// }

Tests coverage should now be at 100%!

Internally, deepClone has also been dropped for a speed boost! 🚀

Helix - v0.0.2

02 Nov 20:06
Compare
Choose a tag to compare

Resolves the es babel build for import use!