-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate generic/jison/create_view test to typescript
- Loading branch information
1 parent
36bcf08
commit c7e788a
Showing
4 changed files
with
65 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 0 additions & 103 deletions
103
src/parsing/parsers/generic/jison/create/create_view.test.json
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
src/parsing/parsers/generic/jison/create/create_view.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
KeywordSuggestion, | ||
parseGenericSql, parseGenericSqlWithoutCursor, | ||
} from '../../../../index'; | ||
import {expect, test} from '@jest/globals'; | ||
|
||
test('should suggest creating VIEW', () => { | ||
const parseResult = parseGenericSql('CREATE ', ''); | ||
|
||
expect(parseResult.errors).toBeUndefined(); | ||
|
||
const suggestions: KeywordSuggestion[] = [ | ||
{ value: 'VIEW', weight: -1 }, | ||
]; | ||
expect(parseResult.suggestKeywords).toEqual(expect.arrayContaining(suggestions)) | ||
}) | ||
|
||
test('should suggest IF NOT EXISTS', () => { | ||
const parseResult = parseGenericSql('CREATE VIEW ', ''); | ||
|
||
expect(parseResult.errors).toBeUndefined(); | ||
|
||
const suggestions: KeywordSuggestion[] = [ | ||
{ value: 'IF NOT EXISTS', weight: -1 }, | ||
]; | ||
expect(parseResult.suggestKeywords).toEqual(expect.arrayContaining(suggestions)) | ||
}) | ||
|
||
test('should suggest AS and COMMENT', () => { | ||
const parseResult = parseGenericSql('CREATE VIEW test_view ', ''); | ||
|
||
expect(parseResult.errors).toBeUndefined(); | ||
|
||
const suggestions: KeywordSuggestion[] = [ | ||
{ value: 'AS', weight: 1 }, | ||
{ value: 'COMMENT', weight: 3 }, | ||
]; | ||
expect(parseResult.suggestKeywords).toEqual(expect.arrayContaining(suggestions)) | ||
}) | ||
|
||
test('should suggest SELECT', () => { | ||
const parseResult = parseGenericSql('CREATE VIEW test_view AS ', ''); | ||
|
||
expect(parseResult.errors).toBeUndefined(); | ||
|
||
const suggestions: KeywordSuggestion[] = [ | ||
{ value: 'SELECT', weight: -1 }, | ||
]; | ||
expect(parseResult.suggestKeywords).toEqual(expect.arrayContaining(suggestions)) | ||
}) | ||
|
||
test('should not report errors on full CREATE VIEW statement', () => { | ||
const parseResult = parseGenericSqlWithoutCursor('CREATE VIEW test_view COMMENT "test" AS SELECT test_field, test_field_2 FROM test_table;'); | ||
expect(parseResult.errors).toBeUndefined(); | ||
}) | ||
|
||
test('should not report errors on full CREATE VIEW statement without comment', () => { | ||
const parseResult = parseGenericSqlWithoutCursor('CREATE VIEW test_view AS SELECT test_field, test_field_2 FROM test_table;'); | ||
expect(parseResult.errors).toBeUndefined(); | ||
}) |