Skip to content

Commit 6b60fed

Browse files
committed
test: align pre-push suites with app refactor
The pre-push package test gate failed on stale test assumptions instead of runtime behavior. Kits now marks the browser canvas-id lookup test as jsdom. Core mocks now expose the current legacy binding context API and assert the supported container compatibility export. Constraint: keep runtime code unchanged; only fix tests that blocked push. Rejected: change package jest environment globally | only one test requires DOM. Confidence: high Scope-risk: narrow Tested: targeted vrender-kits browser-window-canvas-id test. Tested: targeted vrender-core explicit-bindings and index-side-effect tests. Tested: node common/scripts/install-run-rush.js test --only tag:package.
1 parent d0ef1db commit 6b60fed

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

packages/vrender-core/__tests__/unit/core/index-side-effect.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('vrender-core index side effects', () => {
99
test('should not preload legacy modules when importing index', () => {
1010
jest.isolateModules(() => {
1111
const preLoadAllModule = jest.fn();
12+
const legacyBindingContext = { id: 'legacy-context' };
1213

1314
jest.doMock('../../../src/legacy/bootstrap', () => ({
1415
createLegacySingletonProxy: jest.fn(
@@ -22,6 +23,7 @@ describe('vrender-core index side effects', () => {
2223
}
2324
)
2425
),
26+
getLegacyBindingContext: jest.fn(() => legacyBindingContext),
2527
preLoadAllModule,
2628
resolveLegacySingleton: jest.fn(() => ({})),
2729
resolveLegacyNamed: jest.fn()
@@ -30,7 +32,7 @@ describe('vrender-core index side effects', () => {
3032
const mod = require('../../../src/index');
3133

3234
expect(preLoadAllModule).not.toHaveBeenCalled();
33-
expect('container' in mod).toBe(false);
35+
expect(mod.container).toBe(legacyBindingContext);
3436
});
3537
});
3638
});

packages/vrender-core/__tests__/unit/modules/explicit-bindings.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ describe('core explicit bindings', () => {
277277
const layerServiceInstance = { id: 'layer-service' };
278278
const canvasFactoryInstance = { id: 'canvas-factory' };
279279
const context2dFactoryInstance = { id: 'context2d-factory' };
280+
const legacyBindingContext = { id: 'legacy-context' };
280281
const application = {
281282
global: { env: 'browser' }
282283
} as Record<string, unknown>;
@@ -327,6 +328,7 @@ describe('core explicit bindings', () => {
327328
})
328329
),
329330
preLoadAllModule,
331+
getLegacyBindingContext: jest.fn(() => legacyBindingContext),
330332
resolveLegacySingleton,
331333
resolveLegacyNamed
332334
}));
@@ -377,6 +379,7 @@ describe('core explicit bindings', () => {
377379
const mod = require('../../../src/modules');
378380

379381
expect(preLoadAllModule).not.toHaveBeenCalled();
382+
expect(mod.container).toBe(legacyBindingContext);
380383
expect(mod.vglobal).toBe(globalInstance);
381384
expect((mod.graphicUtil as { id: string }).id).toBe('graphic-util');
382385
expect((mod.transformUtil as { id: string }).id).toBe('transform-util');

packages/vrender-kits/__tests__/unit/window/browser-window-canvas-id.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
15
declare const require: any;
26
export {};
37

0 commit comments

Comments
 (0)