I’m using standalone Jasmine to test my Meteor app on Cloud 9 IDE. The issue I’m running into is that the placement of my global objects in my main.js file impacts whether my specs pass or not.
Example Spec:
// spec.js
describe("Console Calculator Addition", function() {
it("should be able to add two numbers", function() {
expect(Calculator.add(1, 2)).toEqual(3);
});
});
This works great:
// main.js
Calculator = {
add: function() {
var sum = 0;
for (var i = 0; i < arguments.length; i++) {
sum += arguments[i];
}
return sum;
}
if (Meteor.isClient) {}
if (Meteor.isServer) {}
This breaks:
// main.js
if (Meteor.isClient) {}
if (Meteor.isServer) {}
Calculator = {
add: function() {
var sum = 0;
for (var i = 0; i < arguments.length; i++) {
sum += arguments[i];
}
return sum;
}
If I try to place Calculator = {…} anywhere except at the top of the file, the specs break. Is there any way around this?