Sinon-Fluent
A package for stubbing fluent interfaces usings Sinon.js
Usage
Creating a basic stub interface
;// const stub = require("sinon-fluent").default // using require // Create stubconst structure = foo: bar: baz: 999 ;const fluentStub = ; // InjectiontestSubjectfluentDependency = fluentStub; // Fluent method chainingfluentStub // returns 999
Creating a stub replacing a key on an existing object
const existingObject = 0 ; const fluentStub = ; existingObject ; // returns 99
Assertion
You can use the with
filter, to assert calls to stubs based on arguments in the function chain.
const fluentStub = ; fluentStub; // 'foo' fluentStubfoobarbazcalled; // truefluentStubfoobarbazcalled; // falsefluentStubfoobarbazcalled; // false