Skip to content

Commit

Permalink
chore: refactor AceEditorWrapper to functional component (#21532)
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneTorap authored Sep 28, 2022
1 parent 546cc18 commit 15c3c34
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import { render, waitFor } from 'spec/helpers/testing-library';
import { QueryEditor } from 'src/SqlLab/types';
import { Store } from 'redux';
import { initialState, defaultQueryEditor } from 'src/SqlLab/fixtures';
import {
queryEditorSetSelectedText,
queryEditorSetFunctionNames,
addTable,
} from 'src/SqlLab/actions/sqlLab';
import AceEditorWrapper from 'src/SqlLab/components/AceEditorWrapper';
import { AsyncAceEditorProps } from 'src/components/AsyncAceEditor';

Expand All @@ -54,11 +49,6 @@ const setup = (queryEditor: QueryEditor, store?: Store) =>
render(
<AceEditorWrapper
queryEditor={queryEditor}
actions={{
queryEditorSetSelectedText,
queryEditorSetFunctionNames,
addTable,
}}
height="100px"
hotkeys={[]}
database={{}}
Expand All @@ -82,27 +72,6 @@ describe('AceEditorWrapper', () => {
);
});

it('renders sql from unsaved change', () => {
const expectedSql = 'SELECT updated_column\nFROM updated_table\nWHERE';
const { getByTestId } = setup(
defaultQueryEditor,
mockStore({
...initialState,
sqlLab: {
...initialState.sqlLab,
unsavedQueryEditor: {
id: defaultQueryEditor.id,
sql: expectedSql,
},
},
}),
);

expect(getByTestId('react-ace')).toHaveTextContent(
JSON.stringify({ value: expectedSql }).slice(1, -1),
);
});

it('renders current sql for unrelated unsaved changes', () => {
const expectedSql = 'SELECT updated_column\nFROM updated_table\nWHERE';
const { getByTestId } = setup(
Expand Down
Loading

0 comments on commit 15c3c34

Please sign in to comment.