Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50675 views
1
module("Director.js", {
2
setup: function() {
3
window.location.hash = "";
4
shared = {};
5
// Init needed keys earlier because of in HTML5 mode the route handler
6
// is executed upon Router.init() and due to that setting shared.fired
7
// in the param test of createTest is too late
8
if (HTML5TEST) {
9
shared.fired = [];
10
shared.fired_count = 0;
11
}
12
},
13
teardown: function() {
14
window.location.hash = "";
15
shared = {};
16
}
17
});
18
19
var shared;
20
21
function createTest(name, config, use, test, initialRoute) {
22
if (typeof use === 'function') {
23
test = use;
24
use = undefined;
25
}
26
27
if (HTML5TEST) {
28
if (use === undefined) {
29
use = {};
30
}
31
32
if (use.run_handler_in_init === undefined) {
33
use.run_handler_in_init = false;
34
}
35
use.html5history = true;
36
}
37
38
// Because of the use of setTimeout when defining onpopstate
39
var innerTimeout = HTML5TEST === true ? 500 : 0;
40
41
asyncTest(name, function() {
42
setTimeout(function() {
43
var router = new Router(config),
44
context;
45
46
if (use !== undefined) {
47
router.configure(use);
48
}
49
50
router.init(initialRoute);
51
52
setTimeout(function() {
53
test.call(context = {
54
router: router,
55
navigate: function(url, callback) {
56
if (HTML5TEST) {
57
router.setRoute(url);
58
} else {
59
window.location.hash = url;
60
}
61
setTimeout(function() {
62
callback.call(context);
63
}, 14);
64
},
65
finish: function() {
66
router.destroy();
67
start();
68
}
69
})
70
}, innerTimeout);
71
}, 14);
72
});
73
};
74
75