In my server side file I have two functions defined for which I want to write test cases which are residing in a file in tests directory.
~PRJ_DIR/server/file1.coffee
calcSha1Hash = (params) ->
.... logic...
anotherFunc = () ->
..somelogic..
x = calcSha1Hash(params)
~PRJ_DIR/tests/server/file1.coffee
MochaWeb?.testOnly () ->
describe.only("Hash generation. ", () ->
it(" calcSha1Hash returns Hash.", (dn) ->
dataDict = {email: '[email protected]'}
hash = calcSha1Hash (dataDict)
chai.assert.isDefined(hash)
dn()
)
)
How is it possible to call the server side func(calcSha1Hash) in my test case in Meteor
Unless there is a meteor-specific way to do this, you can implement the solution from How to Unit Test Private Functions in JavaScript
You will need to have a single global variable (something like
TestAPI
). Then add your functions to it inside of a closure so you can access them from anywhere.Here's an example from the article:
Someone might have something better, but that's a start.