forked from single-spa/single-spa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodejs.spec.js
42 lines (39 loc) · 1.31 KB
/
nodejs.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const singleSpa = require("single-spa");
describe(`nodejs spec`, () => {
describe("activity functions", () => {
it("can still check activity functions in nodejs with a mocked Location object", () => {
singleSpa.registerApplication(
"app1",
/* Note that on the server, System is likely undefined. But this is okay and doesn't cause problems
* because single-spa doesn't call the loading functions when checking activity functions
*/
() => System.import("app1"),
(location) => location.pathname.startsWith("/app1")
);
singleSpa.registerApplication(
"app2",
() => System.import("app2"),
(location) => location.pathname.startsWith("/app2")
);
singleSpa.registerApplication(
"navbar",
() => System.import("navbar"),
(location) => true
);
expect(singleSpa.checkActivityFunctions({ pathname: "/app1" })).toEqual([
"app1",
"navbar",
]);
expect(singleSpa.checkActivityFunctions({ pathname: "/app2" })).toEqual([
"app2",
"navbar",
]);
expect(singleSpa.checkActivityFunctions({ pathname: "/app3" })).toEqual([
"navbar",
]);
});
it("doesn't die if you call singleSpa.start()", () => {
singleSpa.start();
});
});
});