MCPcopy
hub / github.com/flatiron/director / createTest

Function createTest

test/browser/helpers/api.js:21–77  ·  view source on GitHub ↗
(name, config, use, test, initialRoute)

Source from the content-addressed store, hash-verified

19var shared;
20
21function createTest(name, config, use, test, initialRoute) {
22 // We rename to `RouterAlias` for the browserify tests, since we want to be
23 // sure that no code is depending on `window.Router` being available.
24 var Router = window.Router || window.RouterAlias;
25
26 if (typeof use === 'function') {
27 test = use;
28 use = undefined;
29 }
30
31 if (HTML5TEST) {
32 if (use === undefined) {
33 use = {};
34 }
35
36 if (use.run_handler_in_init === undefined) {
37 use.run_handler_in_init = false;
38 }
39 use.html5history = true;
40 }
41
42 // Because of the use of setTimeout when defining onpopstate
43 var innerTimeout = HTML5TEST === true ? 500 : 0;
44
45 asyncTest(name, function() {
46 setTimeout(function() {
47 var router = new Router(config),
48 context;
49
50 if (use !== undefined) {
51 router.configure(use);
52 }
53
54 router.init(initialRoute);
55
56 setTimeout(function() {
57 test.call(context = {
58 router: router,
59 navigate: function(url, callback) {
60 if (HTML5TEST) {
61 router.setRoute(url);
62 } else {
63 window.location.hash = url;
64 }
65 setTimeout(function() {
66 callback.call(context);
67 }, 14);
68 },
69 finish: function() {
70 router.destroy();
71 start();
72 }
73 })
74 }, innerTimeout);
75 }, 14);
76 });
77};

Callers 2

routes-test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…