Skip to content

Commit

Permalink
Revert "chore: refactor AceEditorWrapper to functional component (apa…
Browse files Browse the repository at this point in the history
…che#21532)"

This reverts commit 15c3c34.
  • Loading branch information
sadpandajoe committed Oct 17, 2022
1 parent 6a153fe commit 64596c0
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ 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 @@ -49,6 +54,11 @@ const setup = (queryEditor: QueryEditor, store?: Store) =>
render(
<AceEditorWrapper
queryEditor={queryEditor}
actions={{
queryEditorSetSelectedText,
queryEditorSetFunctionNames,
addTable,
}}
height="100px"
hotkeys={[]}
database={{}}
Expand All @@ -72,6 +82,27 @@ 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 64596c0

Please sign in to comment.