test-streamlets
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Marble Testing for Streamlets

npm i test-streamlets

Marble testing is a useful technique to quickly test behavior of reactive streams by specifying a timeline for events. test-streamlets library provides test-runner/framework agnostic utilities for marble testing streamlets:

import { buffer } from 'streamlets'
import { record, src, T } from 'test-streamlets'

const timeline    = '--1-2---3-4-5-------6-7-|'       // this is our source's emission timeline
const observation = '>-----V-----V-V-V-V-------V'     // this is our sink's behavior timeline
const expected    = '------1-----3-4-5---6-----7,|'   // this is how we expect the end result will be

const source = src(T(timeline))                       // create a source from the timeline
const buffered = buffer(source, 3)                    // buffer the source
const recording = await record(buffered, observation) // record behavior of buffered source using given observation timeline

expect(recording).to.eql(T(expected))                 // assert that the recording matches our expected timeline

Package Sidebar

Install

npm i test-streamlets

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

4.52 kB

Total Files

3

Last publish

Collaborators

  • lorean.victor