Skip to content

Commit c1b9c1e

Browse files
authored
fix(core): Correct exportation of RouterEngine (#12)
* fix(core): Correct exportation of RouterEngine * test: Add unit tests for library exports * chore: Upgrade packages
1 parent 8f85ad0 commit c1b9c1e

File tree

4 files changed

+122
-69
lines changed

4 files changed

+122
-69
lines changed

package-lock.json

Lines changed: 68 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/core/index.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { describe, expect, test } from "vitest";
2+
3+
describe('index', () => {
4+
test("Should export exactly the expected objects.", async () => {
5+
// Arrange.
6+
const expectedList = [
7+
'location',
8+
'RouterEngine',
9+
'joinPaths',
10+
];
11+
12+
// Act.
13+
const lib = await import('./index.js');
14+
15+
// Assert.
16+
for (let item of expectedList) {
17+
expect(item in lib, `The expected object ${item} is not exported.`).toEqual(true);
18+
}
19+
for (let key of Object.keys(lib)) {
20+
expect(expectedList.includes(key), `The library exports object ${key}, which is not expected.`).toEqual(true);
21+
}
22+
});
23+
});

src/lib/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { location } from "./Location.js";
2-
export { RouterEngine as Router, joinPaths } from "./RouterEngine.svelte.js";
2+
export { RouterEngine, joinPaths } from "./RouterEngine.svelte.js";

src/lib/index.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { describe, expect, test } from "vitest";
2+
3+
describe('index', () => {
4+
test("Should export exactly the expected objects.", async () => {
5+
// Arrange.
6+
const expectedList = [
7+
'Link',
8+
'LinkContext',
9+
'Route',
10+
'Router',
11+
'Fallback',
12+
'location',
13+
'RouterTrace',
14+
'init',
15+
'getRouterContext',
16+
'setRouterContext',
17+
];
18+
19+
// Act.
20+
const lib = await import('./index.js');
21+
22+
// Assert.
23+
for (let item of expectedList) {
24+
expect(item in lib, `The expected object ${item} is not exported.`).toEqual(true);
25+
}
26+
for (let key of Object.keys(lib)) {
27+
expect(expectedList.includes(key), `The library exports object ${key}, which is not expected.`).toEqual(true);
28+
}
29+
});
30+
});

0 commit comments

Comments
 (0)