0.1.0 • Published 6 years ago

stakit-test-writer v0.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

stakit-test-writer

A small writer utility for testing Stakit modules

Installation

npm i stakit-test-writer

Example

var tape = require('tape') // with tape-promise in reality
var stakit = require('stakit')
var testWriter = require('stakit-test-writer')

test('it works with stakit', async function (t) {
  t.plan(1)

  var kit = stakit()
    .routes(() => ['/'])
    .render((route, state) => `${route}`)

  var writer = testWriter()

  await kit.output(writer)

  t.ok(typeof writer.get('/index.html') === 'string', 'string was returned')
})

API

writer = testWriter()

Returns a new test writer instance.

writer.write

Stakit compatible write method.

writer.get(filepath)

Returns the mocked value of the "written" file at filepath.

0.1.0

6 years ago