@svadmin/core 0.23.4 → 0.23.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/core",
3
- "version": "0.23.4",
3
+ "version": "0.23.5",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,15 +1,10 @@
1
1
  // Unit tests for RouterProvider implementations
2
- // Router provider tests need a DOM environment.
3
- // Skip if window is not available (CI without happy-dom).
4
- import { describe, test, expect } from 'bun:test';
2
+ // Router provider tests need a DOM environment or a mock.
3
+ import { describe, test, expect, beforeEach } from 'bun:test';
5
4
  import { createHashRouterProvider, createHistoryRouterProvider } from './router-provider';
6
- import { GlobalRegistrator } from '@happy-dom/global-registrator';
7
-
8
- GlobalRegistrator.register();
9
-
10
- const hasWindow = typeof globalThis.window !== 'undefined';
11
5
 
12
6
  describe('createHashRouterProvider (unit — no DOM)', () => {
7
+
13
8
  test('returns provider with go, back, parse methods', () => {
14
9
  const provider = createHashRouterProvider();
15
10
  expect(typeof provider.go).toBe('function');
@@ -32,8 +27,20 @@ describe('createHistoryRouterProvider (unit — no DOM)', () => {
32
27
  });
33
28
  });
34
29
 
35
- // DOM-dependent tests — only run if window is available
36
- describe.skipIf(!hasWindow)('createHashRouterProvider (DOM)', () => {
30
+ // DOM-dependent tests — mocked window if not exists
31
+ describe('createHashRouterProvider (with mock DOM)', () => {
32
+ beforeEach(() => {
33
+ if (typeof globalThis.window === 'undefined') {
34
+ let _hash = '';
35
+ (globalThis as any).window = {
36
+ location: {
37
+ get hash() { return _hash ? (_hash.startsWith('#') ? _hash : '#' + _hash) : ''; },
38
+ set hash(val) { _hash = val; }
39
+ }
40
+ };
41
+ }
42
+ });
43
+
37
44
  test('parse returns empty segments for root', () => {
38
45
  window.location.hash = '';
39
46
  const provider = createHashRouterProvider();
@@ -72,3 +79,4 @@ describe.skipIf(!hasWindow)('createHashRouterProvider (DOM)', () => {
72
79
  expect(window.location.hash).toBe('#/users');
73
80
  });
74
81
  });
82
+