Hello,
We are now able to test our helpers with setting reactive vars and such from Tinytest.
This is how it works for us.
Maybe it is not very nice looking way, but it does not require to run 2 environments simultaneous as with Velocity
describe 'Template integration', ->
# render Template to view and attach to body if it exist
# in our Tinytest case body does not exist
# in Velocity client integration it does
myView = Blaze.render(Template.productAvailableShops, $('body').get(0))
console.log 'myView:'
console.log myView
# use internal instance object, cause it was not attached to DOM
# in Velocity we can use normal myView.templateInstance()
instance = myView._templateInstance
console.log 'instance:'
console.log instance
# mock Template.instance() used in helper
Template.instance = ->
return instance
# change template level ReactiveVar used in helper
instance.currentPriceSort.set(
{
_id: 'descending'
label: 'Descending'
}
)
returnVal = Template.productAvailableShops.__helpers.get('eshopDepots')(testShopFeed)
console.log 'helper returns:'
console.log returnVal
it 'should return descending', ->
expect(returnVal).to.equal(descendingExpectedResults)
instance.currentPriceSort.set(
{
_id: 'ascending'
label: 'Ascending'
}
)
returnVal = Template.productAvailableShops.__helpers.get('eshopDepots')(testShopFeed)
console.log 'helper ascend returns:'
console.log returnVal
it 'should return ascending', ->
expect(returnVal).to.equal(ascendingExpectedResults)
@Sanjo thx for pointing me to right direction