Say I had a function defined like so:
import {RxHR} from '@akanass/rx-http-request'
(arg) => RxHR.get(`https://third.party.com/${arg}`)
.take(1)
.pluck('body')
.map(JSON.parse)
I now wish to test this function (call it importedFunction
) say with mocha and nock, so I write a test, expecting it to be red so I can red green refactor:
describe('It makes the request', () => {
before(() => {
nock(`https://third.party.com`)
.get(`/potato`)
.reply(200, 'tomato')
})
it('makes the request', () => {
return importedFunction(potato)
.subscribe((response) => assert.equal(true, false))
})
})
And my test passes (which it should not). So I add a console.log in my subscribe and it turns out my subscriber function is in fact not running.
How can I test an RxJS request? And why doesn't my implementation work?
via Abraham P
No comments:
Post a Comment