0.1.4 • Published 9 years ago

highland-fixture v0.1.4

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
9 years ago

highland-fixture

Wrap highland streams to record test fixtures - similar to how VCR and sepia create fixtures by patching http.

describe("stream recorder", function() {

  process.env.FIXTURE_DIR = '.fixtures' // default

  var exampleStreamGetter = function (err, max) {
    var count = 0
    return _(function (push, next) {
      setTimeout(function () {
        if (count === max) {
          push(err, { count: count })
          push(null, _.nil)
        } else {
          push(null, { count: count })
          count += 1
          next()
        }
      }, 0)
    })
  }

  it("records a stream when no recording exists", function(callback) {
    var recordedExample = recordedStream(exampleStreamGetter, 'example')
    var exampleStream = recordedExample('test error', 10)
    exampleStream
      .done(function () {
        fs.stat(exampleStream.streamFile, function (err, stat) {
          expect(err).toBe(null) // file exists
          callback()
        })
      })
  });

  it("records different streams given different arguments", function() {
    var recordedExample = recordedStream(exampleStreamGetter, 'example')
    var firstExampleStream = recordedExample('test error', 10)
    var secondExampleStream = recordedExample('test error', 20)
    expect(firstExampleStream.streamFile)
      .not.toEqual(secondExampleStream.streamFile)
  });
})
0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago