Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libs/features/sql-editor/src/sql-editor.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import { SqlEditorComponent } from './sql-editor.component';
import { By } from '@angular/platform-browser';
import { CodeEditor } from '@acrodata/code-editor';

// Simulate a user edit: dispatch a doc change without the `External` annotation
// that `writeValue`/`setValue` use, so the editor propagates it through ngModel.
const typeInEditor = (editor: CodeEditor, value: string): void => {
editor.view.dispatch({
changes: { from: 0, to: editor.view.state.doc.length, insert: value },
});
};

export class SqlEditorPage extends PageObject<SqlEditorComponent> {
readonly DT = 'ngx-datatable';

Expand Down Expand Up @@ -80,7 +88,7 @@ describe('SqlEditorComponent', () => {
const { page, mysqlQueryService, codeEditorInstance } = setup();
const customQuery = 'SELECT col FROM table WHERE col > 10';

codeEditorInstance.writeValue(customQuery);
typeInEditor(codeEditorInstance, customQuery);
page.clickElement(page.executeBtn);

expect(mysqlQueryService.query).toHaveBeenCalledWith(customQuery);
Expand Down Expand Up @@ -175,7 +183,7 @@ describe('SqlEditorComponent', () => {
const spy = vi.spyOn(TestBed.inject(ClipboardService), 'copyFromContent').mockImplementation(() => undefined);
const customQuery = '-- some text that will be copied';

codeEditorInstance.writeValue(customQuery);
typeInEditor(codeEditorInstance, customQuery);
page.clickElement(page.copyBtn);

expect(spy).toHaveBeenCalledWith(customQuery);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"prepare": "husky install"
},
"dependencies": {
"@acrodata/code-editor": "0.5.1",
"@acrodata/code-editor": "0.6.1",
"@codemirror/lang-sql": "6.10.0",
"@ngx-translate/core": "17.0.0",
"@ngx-translate/http-loader": "17.0.0",
Expand Down
Loading