I would like to use Jasmine for unit testing in one of my dojo projects. The problem is that we have a global app object, which is needed for nearly every other object we create.
The app object is responsible for initializing the application and building up the DOM, but this is the problem. When I create the app object in my test it tries to manipulate not existing DOM elements and I got an error.
Here is a little example of the situation:
/* app.js */
define(['dojo/_base/declare', 'dojo/dom-construct'],
function(declare, domConstruct){
return declare([], {
constructor: function() {
this.renderGui();
},
renderGui: function() {
var gui = domConstruct.create('div', {innerHTML: 'Hello World!'});
domConstruct.place(gui, 'content');
},
importantFunction: function() {
return 100;
}
});
})
If I want to test the importantFunction I have to create an instance of app, but in the constructor it calls the renderGui function where i got the error, because there is no element with the id 'content'.
Hope you guys can help me. Thanks in advance!