test-vector
v0.1.0
Published
general purpose tools for testing behavioral contracts
Downloads
492
Readme
Test Vector
This library is inspired by the talk Integrated Tests Are A Scam.
API
memoize (callback)
Memoizes the callback function so that it will record its inputs and outputs.
Returns
memoized
: the memoized callback functionvector
: an AsyncIterable recording of the callback function's inputs and outputs
mockCaller (vector, callback)
Calls the callback function repeatedly with inputs from vector
while making sure the outputs match expectations.
Returns
a promise that resolves when complete
mockFunction (vector)
Creates a mock function from a test vector recording. vector
is an AsyncIterable.
Returns
mock
: a new function that behaves like an earlier memoized function based on the givenvector
status
: a promise that resolves when the last output fromvector
is returned bymock
Copyright
Copyright 2017 David Braun
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
these files except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
. Unless required by
applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.