-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathtokenSuggestion.test.ts
82 lines (73 loc) · 2.18 KB
/
tokenSuggestion.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import fs from 'fs';
import path from 'path';
import { FlinkSQL } from 'src/parser/flink';
import { CaretPosition } from 'src/parser/common/types';
import { commentOtherLine } from 'test/helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
describe('Flink SQL Token Suggestion', () => {
const flink = new FlinkSQL();
test('Use Statement ', () => {
const pos: CaretPosition = {
lineNumber: 3,
column: 5,
};
const suggestion = flink.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArray(['MODULES', 'CATALOG']);
});
test('Create Statement ', () => {
const pos: CaretPosition = {
lineNumber: 5,
column: 8,
};
const suggestion = flink.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArray([
'CATALOG',
'FUNCTION',
'TEMPORARY',
'VIEW',
'DATABASE',
'TABLE',
]);
});
test('Show Statement ', () => {
const pos: CaretPosition = {
lineNumber: 7,
column: 6,
};
const suggestion = flink.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toMatchUnorderedArray([
'MODULES',
'FULL',
'FUNCTIONS',
'USER',
'CREATE',
'COLUMNS',
'TABLES',
'CURRENT',
'CATALOGS',
'DATABASES',
'VIEWS',
'JARS',
]);
});
test('Suggestion in new line', () => {
const pos: CaretPosition = {
lineNumber: 10,
column: 2,
};
const suggestion = flink.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, [9, 11]),
pos
)?.keywords;
expect(suggestion.length).not.toBe(0);
});
});