Below I have a test for express middleware. I'm looking to use sinon to mock these callbacks, rather then maintaining global state for thee variables.
it('should return html', async () => {
const val = []
const req = {}
const res = {send: (recieved) => {val.push(recieved)}}
const next = (e) => {throw e}
expect(val).to.be.length(0)
await expressMiddleware(alpha)(req, res, next)
const expectation = 'response sent'
expect(val).to.be.length(1)
expect(val[0]).to.be(expectation)
})
Aucun commentaire:
Enregistrer un commentaire