Problem:
Stubbed functions that are called by a Meteor method behave differently on the client and server.
This test passes on the server.
But on the client, the stub does not work and I get an error thrown by funcOne
, which means that funcOne
did not return true.
Using:
- Meteor 1.3-rc.4
- avital:mocha
- practicalmeteor:chai
- practicalmeteor:sinon
Code:
```coffee describe 'items', -> describe 'addItem', ->
item = null
beforeEach ->
Meteor.call 'emptyCollection', 'Items'
item = new Item({
name : "Thing"
text: "Lets get this test working"
})
sinon.stub utils, 'funcOne', -> true
afterEach ->
utils.funcOne.restore()
it 'should add an item to DB', ->
Meteor.call('addItem', item)
itemInDb = Items.findOne()
expect(itemInDb).to.be.a('object')
expect(itemInDb).to.have.property('_id')
```
Tried:
I have tried variations of restoring the stubbed method only on the server or not restoring at all, which does give me different errors, but still no joy.
I have looked into load order issues:
- my tests are in the same folder as the methods root/methods/items.coffee
- App.utils file is in root/lib/
- I am currently not using imports/exports folders
Help?
Anybody have any ideas... Thanks.
Aucun commentaire:
Enregistrer un commentaire