Published
Edited
Sep 1, 2018
Insert cell
Insert cell
Insert cell
Insert cell
// sinon = require('sinon')
Insert cell
Insert cell
// assert = require('sinon').assert
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
mockedFn('A')
sinon.assert.calledWith(mockedFn, 'NOT A')
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
assert.deepEqual(mock.args[0], ['A'])
assert.deepEqual(mock.args[1], ['NOT B'])
assert.deepEqual(mock.args[2], ['C'])
}
Insert cell
Insert cell
Insert cell
Insert cell
assert.deepEqual(mock.args[1], ['NOT B'], "expected <function name> to be called with args:")
Insert cell
Insert cell
Insert cell
Insert cell
{
const context = "expected <function name> to be called with args:"
assert.deepEqual(mock.args[0], ['A'], context)
assert.deepEqual(mock.args[1], ['NOT B'], context)
assert.deepEqual(mock.args[2], ['C'], context)
}
Insert cell
Insert cell
Insert cell
{
sinon.assert.callOrder(
mock.withArgs('A'),
mock.withArgs('NOT B'),
mock.withArgs('C'),
)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
sinon.assert.calledWith(mock.firstCall, 'A')
sinon.assert.calledWith(mock.secondCall, 'B')
sinon.assert.calledWith(mock.thirdCall, 'C')
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more