From 3fd482656a4803e3b6451a6b93414b0fbe210936 Mon Sep 17 00:00:00 2001 From: vitPinchuk Date: Mon, 25 Nov 2024 11:16:55 +0300 Subject: [PATCH 1/2] upd AutosizeCodeEditor --- package-lock.json | 2 +- packages/components/package.json | 2 +- .../AutosizeCodeEditor.test.tsx | 18 ++++++++++++++- .../AutosizeCodeEditor/AutosizeCodeEditor.tsx | 22 +++++++++++++++---- packages/components/tsconfig.json | 2 +- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3216d62..4c5cdf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23062,7 +23062,7 @@ }, "packages/components": { "name": "@volkovlabs/components", - "version": "3.3.0", + "version": "3.5.0", "license": "Apache-2.0", "dependencies": { "@emotion/css": "^11.11.2", diff --git a/packages/components/package.json b/packages/components/package.json index 30b0ebf..d7a63b8 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -89,5 +89,5 @@ "typecheck": "tsc --emitDeclarationOnly false --noEmit" }, "types": "dist/index.d.ts", - "version": "3.5.0" + "version": "3.5.1" } diff --git a/packages/components/src/components/AutosizeCodeEditor/AutosizeCodeEditor.test.tsx b/packages/components/src/components/AutosizeCodeEditor/AutosizeCodeEditor.test.tsx index d62fc52..af32fef 100644 --- a/packages/components/src/components/AutosizeCodeEditor/AutosizeCodeEditor.test.tsx +++ b/packages/components/src/components/AutosizeCodeEditor/AutosizeCodeEditor.test.tsx @@ -17,6 +17,21 @@ const InTestIds = { field: createSelector('data-testid field'), }; +const defaultModel = { + setEOL: jest.fn(), +}; + +const defalutMonaco = { + editor: { + EndOfLineSequence: { + '0': 'LF', + '1': 'CRLF', + LF: 0, + CRLF: 1, + }, + }, +} as any; + const editor = { getPosition: () => ({ lineNumber: 12, @@ -27,6 +42,7 @@ const editor = { revealLineInCenter: (value: any) => value, getSelection: () => null, executeEdits: (source: any, edits: any) => true, + getModel: () => defaultModel, }; /** @@ -46,7 +62,7 @@ jest.mock('@grafana/ui', () => ({ /** * Call the onEditorDidMount callback with the editor instance */ - onEditorDidMount(editor, ''); + onEditorDidMount(editor, defalutMonaco); return (