You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

factor-in

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

factor-in

A factory of factory functions. Share and extend object data.

1.1.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

factor-in

NPM version build status Test coverage js-standard-style

A factory of factory functions. Share and extend object data.

Install

$ npm install --save factor-in

Usage

import factorIn from 'factor-in'

// Create our base object data we expect all
// factory functions to inherit from.
const f = factorIn ({
  foo () {},
  bar () {}
})

var obj = f ({ baz: 'Baz', qux: 'Qux' })
//=> {foo: foo(), bar: bar(), baz: 'Baz', qux: 'Qux'}
test('Demo component', nest => {
  // fixture to be shared across nested tests
  const fixture = factorIn({
    setWord () {},
    setMode () {}
  })

  nest.test('...with basic fixture', t => {
    const el = <Hello actions={ fixture() } />
    //> { setWord: function setWord () {}, setMode: function setMode () {} }
    t.equal(actual, expected, 'should have common methods')
    t.end()
  })

  nest.test('...with extended fixture', t => {
    const extendedFixture = fixture({ setAction () {} })
    const el = <Hello actions={ extendedFixture } />
    //> { setWord: function setWord () {}, setMode: function setMode() {}, setAction: function setAction() {} }
    t.equal(actual, expected, 'should have common and extended methods')
    t.end()
  })
})

License

MIT © Chris Buttery

Keywords

javascript

FAQs

Package last updated on 27 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts