Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

chore(base-sheets): move focusUniverInstance to test bed file (#185)

Dushusirf1476dc88a22
diff --git a/packages/base-sheets/src/commands/commands/__tests__/clear-selection-command.spec.ts b/packages/base-sheets/src/commands/commands/__tests__/clear-selection-command.spec.ts
index a7b940b7b8..25127c931c 100644
--- a/packages/base-sheets/src/commands/commands/__tests__/clear-selection-command.spec.ts
+++ b/packages/base-sheets/src/commands/commands/__tests__/clear-selection-command.spec.ts
@@ -24,7 +24,6 @@ describe('Test clear selection content commands', () => {
let univer: Univer;
let get: Injector['get'];
let commandService: ICommandService;
- let currentUniverService: ICurrentUniverService;
beforeEach(() => {
const testBed = createCommandTestBed();
@@ -37,9 +36,6 @@ describe('Test clear selection content commands', () => {
commandService.registerCommand(ClearSelectionAllCommand);
commandService.registerCommand(SetRangeValuesCommand);
commandService.registerCommand(SetRangeValuesMutation);
-
- currentUniverService = get(ICurrentUniverService);
- currentUniverService.focusUniverInstance('test'); // used in undo
});
afterEach(() => {
diff --git a/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts
index e4f5e396fe..894da88b52 100644
--- a/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts
+++ b/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts
@@ -1,4 +1,4 @@
-import { IWorkbookConfig, LocaleType, Plugin, PluginType, Univer } from '@univerjs/core';
+import { ICurrentUniverService, IWorkbookConfig, LocaleType, Plugin, PluginType, Univer } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
import { SelectionManagerService } from '../../../services/selection-manager.service';
@@ -65,6 +65,10 @@ export function createCommandTestBed() {
throw new Error('[TestPlugin]: not hooked on!');
}
+ // focus, used in undo
+ const currentUniverService = (get as Injector['get'])(ICurrentUniverService);
+ currentUniverService.focusUniverInstance('test');
+
return {
univer,
get,
diff --git a/packages/base-sheets/src/commands/commands/__tests__/set-range-values-command.spec.ts b/packages/base-sheets/src/commands/commands/__tests__/set-range-values-command.spec.ts
index 5cf41dabc8..40a8057abe 100644
--- a/packages/base-sheets/src/commands/commands/__tests__/set-range-values-command.spec.ts
+++ b/packages/base-sheets/src/commands/commands/__tests__/set-range-values-command.spec.ts
@@ -24,7 +24,6 @@ describe('Test set range values commands', () => {
let univer: Univer;
let get: Injector['get'];
let commandService: ICommandService;
- let currentUniverService: ICurrentUniverService;
let selectionManager: SelectionManagerService;
let getValue: () => any;
let getStyle: () => any;
@@ -38,9 +37,6 @@ describe('Test set range values commands', () => {
commandService.registerCommand(SetRangeValuesCommand);
commandService.registerCommand(SetRangeValuesMutation);
- currentUniverService = get(ICurrentUniverService);
- currentUniverService.focusUniverInstance('test'); // used in undo
-
selectionManager = get(SelectionManagerService);
selectionManager.setCurrentSelection({
pluginName: NORMAL_SELECTION_PLUGIN_NAME,
diff --git a/packages/base-sheets/src/commands/commands/__tests__/set-style-command.spec.ts b/packages/base-sheets/src/commands/commands/__tests__/set-style-command.spec.ts
index ec8d84ea93..3f9315ccb9 100644
--- a/packages/base-sheets/src/commands/commands/__tests__/set-style-command.spec.ts
+++ b/packages/base-sheets/src/commands/commands/__tests__/set-style-command.spec.ts
@@ -19,7 +19,6 @@ describe('Test style commands', () => {
let univer: Univer;
let get: Injector['get'];
let commandService: ICommandService;
- let currentUniverService: ICurrentUniverService;
beforeEach(() => {
const testBed = createCommandTestBed();
@@ -30,9 +29,6 @@ describe('Test style commands', () => {
commandService.registerCommand(SetBoldCommand);
commandService.registerCommand(SetStyleCommand);
commandService.registerCommand(SetRangeStyleMutation);
-
- currentUniverService = get(ICurrentUniverService);
- currentUniverService.focusUniverInstance('test'); // used in undo
});
afterEach(() => {