mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
Fix test for new module route
The js base route is now js/modules/%modulename%/%file%. This commit reflects these changes in the testcases refs #4092 refs #3735
This commit is contained in:
parent
fc83dfb4ef
commit
33b4a2ced0
@ -9,12 +9,12 @@
|
|||||||
// {{LICENSE_HEADER}}
|
// {{LICENSE_HEADER}}
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var rjsmock = require("requiremock.js");
|
var rjsmock = require("requiremock.js");
|
||||||
var asyncMock = require("asyncmock.js");
|
|
||||||
|
|
||||||
requireNew("icinga/module.js");
|
var BASE = "../../../../public/js/";
|
||||||
|
require(BASE+"icinga/module.js");
|
||||||
|
|
||||||
var module = rjsmock.getDefine();
|
var module = rjsmock.getDefine();
|
||||||
GLOBAL.document = $('body');
|
GLOBAL.document = $('body');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test module that only uses eventhandlers and
|
* Test module that only uses eventhandlers and
|
||||||
* no custom logic
|
* no custom logic
|
||||||
@ -195,9 +195,6 @@ describe('The icinga module bootstrap', function() {
|
|||||||
var testClick = false;
|
var testClick = false;
|
||||||
rjsmock.registerDependencies({
|
rjsmock.registerDependencies({
|
||||||
"icinga/module": module,
|
"icinga/module": module,
|
||||||
"icinga/util/async" : {
|
|
||||||
registerHeaderListener: function() {}
|
|
||||||
},
|
|
||||||
"modules/test/test" : {
|
"modules/test/test" : {
|
||||||
eventHandler: {
|
eventHandler: {
|
||||||
"a.test" : {
|
"a.test" : {
|
||||||
@ -217,7 +214,7 @@ describe('The icinga module bootstrap', function() {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
tearDownTestDOM();
|
tearDownTestDOM();
|
||||||
requireNew("icinga/icinga.js");
|
require(BASE+"icinga/icinga.js");
|
||||||
var icinga = rjsmock.getDefine();
|
var icinga = rjsmock.getDefine();
|
||||||
$('body').append($("<a class='test'></a>"));
|
$('body').append($("<a class='test'></a>"));
|
||||||
$('a.test').click();
|
$('a.test').click();
|
||||||
@ -226,55 +223,4 @@ describe('The icinga module bootstrap', function() {
|
|||||||
should.equal(icinga.getFailedModules()[0].name, "test2");
|
should.equal(icinga.getFailedModules()[0].name, "test2");
|
||||||
tearDownTestDOM();
|
tearDownTestDOM();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should load modules lazily when discovering a X-Icinga-Enable-Module header", function() {
|
|
||||||
rjsmock.purgeDependencies();
|
|
||||||
|
|
||||||
requireNew("icinga/util/async.js");
|
|
||||||
var async = rjsmock.getDefine();
|
|
||||||
|
|
||||||
rjsmock.registerDependencies({
|
|
||||||
"icinga/module": module,
|
|
||||||
"icinga/util/async": async,
|
|
||||||
"modules/test/test" : {
|
|
||||||
eventHandler: {
|
|
||||||
"a.test" : {
|
|
||||||
click : function() {
|
|
||||||
testClick = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"icinga/container" : {
|
|
||||||
registerAsyncMgr: function() {},
|
|
||||||
initializeContainers: function() {}
|
|
||||||
},
|
|
||||||
"modules/list" : [
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDownTestDOM();
|
|
||||||
|
|
||||||
requireNew("icinga/icinga.js");
|
|
||||||
var icinga = rjsmock.getDefine();
|
|
||||||
|
|
||||||
var testClick = false;
|
|
||||||
// The module shouldn't be loaded
|
|
||||||
$('body').append($("<a class='test'></a>"));
|
|
||||||
$('a.test').click();
|
|
||||||
should.equal(testClick, false, "Unregistered module was loaded");
|
|
||||||
|
|
||||||
asyncMock.setNextAsyncResult(async,"result", false, {
|
|
||||||
"X-Icinga-Enable-Module" : "test"
|
|
||||||
});
|
|
||||||
async.createRequest();
|
|
||||||
// The module shouldn't be loaded
|
|
||||||
$('body').append($("<a class='test'></a>"));
|
|
||||||
$('a.test').click();
|
|
||||||
should.equal(testClick, true, "Module wasn't automatically loaded on header!");
|
|
||||||
|
|
||||||
|
|
||||||
tearDownTestDOM();
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user