0.2.0 • Published 8 years ago

stub-class-unit-tests v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

stub-class-unit-tests

npm Dependencies Build Status Coverage Status JavaScript Standard Style

Stubs unit tests for ES2015 classes. Uses Mocha + Chai.

This is very much a work in progress.

Usage

import stubClassUnitTests from 'stub-class-unit-tests'
import fs from 'fs'

class MyClass {
  constructor () {
    this._foo = 0
  }

  get foo () {
    return this._foo
  }

  set foo (value) {
    this._foo = value
  }

  add (num) {
    this._foo += num
  }
}

const jsCode = stubClassUnitTests(MyClass)
fs.writeFileSync('test.js', jsCode, 'utf8')

Options

className

Override the class name. Defaults to constructor.name.

importPath

Path to the module that exports the class, relative to where you're going to save the test source code. Used to generate an import statement.

importType

Either 'default' (default export, the default) or 'named' (named export). Determines how the class will be imported from importPath.

Author

Tim De Pauw

License

MIT