Skip to content

Commit 24623f8

Browse files
committed
test: suggestion wordRanges with range
1 parent 18e55e4 commit 24623f8

15 files changed

+317
-15
lines changed

test/parser/flink/suggestion/multipleStatement.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ describe('FlinkSQL Multiple Statements Syntax Suggestion', () => {
3636
);
3737

3838
expect(suggestion).not.toBeUndefined();
39-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
39+
expect(suggestion?.wordRanges?.length).toBe(2);
40+
expect(suggestion?.wordRanges).toEqual([
41+
{
42+
text: 'db',
43+
line: 16,
44+
startIndex: 306,
45+
endIndex: 307,
46+
startColumn: 14,
47+
endColumn: 16,
48+
},
49+
{
50+
text: '.',
51+
line: 16,
52+
startIndex: 308,
53+
endIndex: 308,
54+
startColumn: 16,
55+
endColumn: 17,
56+
},
57+
]);
4058
});
4159

4260
test('Insert into table ', () => {

test/parser/flink/suggestion/syntaxSuggestion.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@ describe('Flink SQL Syntax Suggestion', () => {
3232
);
3333

3434
expect(suggestion).not.toBeUndefined();
35-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['cat']);
35+
expect(suggestion?.wordRanges?.length).toBe(1);
36+
expect(suggestion?.wordRanges).toEqual([
37+
{
38+
text: 'cat',
39+
line: 1,
40+
startIndex: 13,
41+
endIndex: 15,
42+
startColumn: 14,
43+
endColumn: 17,
44+
},
45+
]);
3646
});
3747

3848
test('Select table', () => {

test/parser/hive/suggestion/multipleStatement.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ describe('HiveSQL Multiple Statements Syntax Suggestion', () => {
3636
);
3737

3838
expect(suggestion).not.toBeUndefined();
39-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
39+
expect(suggestion?.wordRanges?.length).toBe(2);
40+
expect(suggestion?.wordRanges).toEqual([
41+
{
42+
text: 'db',
43+
line: 9,
44+
startIndex: 272,
45+
endIndex: 273,
46+
startColumn: 14,
47+
endColumn: 16,
48+
},
49+
{
50+
text: '.',
51+
line: 9,
52+
startIndex: 274,
53+
endIndex: 274,
54+
startColumn: 16,
55+
endColumn: 17,
56+
},
57+
]);
4058
});
4159

4260
test('Insert into table ', () => {

test/parser/hive/suggestion/syntaxSuggestion.test.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,33 @@ describe('Hive SQL Syntax Suggestion', () => {
3232
);
3333

3434
expect(suggestion).not.toBeUndefined();
35-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
35+
expect(suggestion?.wordRanges?.length).toBe(3);
36+
expect(suggestion?.wordRanges).toEqual([
37+
{
38+
text: 'db',
39+
line: 1,
40+
startIndex: 12,
41+
endIndex: 13,
42+
startColumn: 13,
43+
endColumn: 15,
44+
},
45+
{
46+
text: '.',
47+
line: 1,
48+
startIndex: 14,
49+
endIndex: 14,
50+
startColumn: 15,
51+
endColumn: 16,
52+
},
53+
{
54+
text: 'tb',
55+
line: 1,
56+
startIndex: 15,
57+
endIndex: 16,
58+
startColumn: 16,
59+
endColumn: 18,
60+
},
61+
]);
3662
});
3763

3864
test('Select table ', () => {

test/parser/impala/suggestion/multipleStatement.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ describe('ImpalaSQL Multiple Statements Syntax Suggestion', () => {
3636
);
3737

3838
expect(suggestion).not.toBeUndefined();
39-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
39+
expect(suggestion?.wordRanges?.length).toBe(2);
40+
expect(suggestion?.wordRanges).toEqual([
41+
{
42+
text: 'db',
43+
line: 9,
44+
startIndex: 203,
45+
endIndex: 204,
46+
startColumn: 14,
47+
endColumn: 16,
48+
},
49+
{
50+
text: '.',
51+
line: 9,
52+
startIndex: 205,
53+
endIndex: 205,
54+
startColumn: 16,
55+
endColumn: 17,
56+
},
57+
]);
4058
});
4159

4260
test('Insert into table ', () => {

test/parser/impala/suggestion/syntaxSuggestion.test.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,33 @@ describe('Impala SQL Syntax Suggestion', () => {
2626
);
2727

2828
expect(suggestion).not.toBeUndefined();
29-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['cat', '.', 'a']);
29+
expect(suggestion?.wordRanges?.length).toBe(3);
30+
expect(suggestion?.wordRanges).toEqual([
31+
{
32+
text: 'cat',
33+
line: 1,
34+
startIndex: 14,
35+
endIndex: 16,
36+
startColumn: 15,
37+
endColumn: 18,
38+
},
39+
{
40+
text: '.',
41+
line: 1,
42+
startIndex: 17,
43+
endIndex: 17,
44+
startColumn: 18,
45+
endColumn: 19,
46+
},
47+
{
48+
text: 'a',
49+
line: 1,
50+
startIndex: 18,
51+
endIndex: 18,
52+
startColumn: 19,
53+
endColumn: 20,
54+
},
55+
]);
3056
});
3157

3258
test('Function call', () => {

test/parser/mysql/suggestion/multipleStatement.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ describe('MySQL Multiple Statements Syntax Suggestion', () => {
3636
);
3737

3838
expect(suggestion).not.toBeUndefined();
39-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
39+
expect(suggestion?.wordRanges?.length).toBe(2);
40+
expect(suggestion?.wordRanges).toEqual([
41+
{
42+
text: 'db',
43+
line: 9,
44+
startIndex: 306,
45+
endIndex: 307,
46+
startColumn: 14,
47+
endColumn: 16,
48+
},
49+
{
50+
text: '.',
51+
line: 9,
52+
startIndex: 308,
53+
endIndex: 308,
54+
startColumn: 16,
55+
endColumn: 17,
56+
},
57+
]);
4058
});
4159

4260
test('Insert into table ', () => {

test/parser/mysql/suggestion/syntaxSuggestion.test.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,33 @@ describe('MySQL Syntax Suggestion', () => {
3030
);
3131

3232
expect(suggestion).not.toBeUndefined();
33-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
33+
expect(suggestion?.wordRanges?.length).toBe(3);
34+
expect(suggestion?.wordRanges).toEqual([
35+
{
36+
text: 'db',
37+
line: 1,
38+
startIndex: 12,
39+
endIndex: 13,
40+
startColumn: 13,
41+
endColumn: 15,
42+
},
43+
{
44+
text: '.',
45+
line: 1,
46+
startIndex: 14,
47+
endIndex: 14,
48+
startColumn: 15,
49+
endColumn: 16,
50+
},
51+
{
52+
text: 'tb',
53+
line: 1,
54+
startIndex: 15,
55+
endIndex: 16,
56+
startColumn: 16,
57+
endColumn: 18,
58+
},
59+
]);
3460
});
3561

3662
test('Select table ', () => {

test/parser/postgresql/suggestion/multipleStatement.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ describe('PgSQL Multiple Statements Syntax Suggestion', () => {
6969
);
7070

7171
expect(suggestion).not.toBeUndefined();
72-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
72+
expect(suggestion?.wordRanges?.length).toBe(2);
73+
expect(suggestion?.wordRanges).toEqual([
74+
{
75+
text: 'db',
76+
line: 21,
77+
startIndex: 682,
78+
endIndex: 683,
79+
startColumn: 62,
80+
endColumn: 64,
81+
},
82+
{
83+
text: '.',
84+
line: 21,
85+
startIndex: 684,
86+
endIndex: 684,
87+
startColumn: 64,
88+
endColumn: 65,
89+
},
90+
]);
7391
});
7492
});

test/parser/postgresql/suggestion/suggestionWithEntity.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,17 @@ describe('PostgreSql Syntax Suggestion with collect entity', () => {
166166
(syn) => syn.syntaxContextType === EntityContextType.COLUMN
167167
);
168168
expect(suggestion).not.toBeUndefined();
169-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['a_column']);
169+
expect(suggestion?.wordRanges?.length).toBe(1);
170+
expect(suggestion?.wordRanges).toEqual([
171+
{
172+
text: 'a_column',
173+
line: 13,
174+
startIndex: 399,
175+
endIndex: 406,
176+
startColumn: 27,
177+
endColumn: 35,
178+
},
179+
]);
170180

171181
const entities = postgre.getAllEntities(sql, pos);
172182
expect(entities.length).toBe(1);

test/parser/postgresql/suggestion/syntaxSuggestion.test.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,33 @@ describe('Postgre SQL Syntax Suggestion', () => {
3232
);
3333

3434
expect(suggestion).not.toBeUndefined();
35-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
35+
expect(suggestion?.wordRanges?.length).toBe(3);
36+
expect(suggestion?.wordRanges).toEqual([
37+
{
38+
text: 'db',
39+
line: 3,
40+
startIndex: 88,
41+
endIndex: 89,
42+
startColumn: 13,
43+
endColumn: 15,
44+
},
45+
{
46+
text: '.',
47+
line: 3,
48+
startIndex: 90,
49+
endIndex: 90,
50+
startColumn: 15,
51+
endColumn: 16,
52+
},
53+
{
54+
text: 'tb',
55+
line: 3,
56+
startIndex: 91,
57+
endIndex: 92,
58+
startColumn: 16,
59+
endColumn: 18,
60+
},
61+
]);
3662
});
3763

3864
test('Alter table ', () => {

test/parser/spark/suggestion/multipleStatement.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ describe('SparkSQL Multiple Statements Syntax Suggestion', () => {
3636
);
3737

3838
expect(suggestion).not.toBeUndefined();
39-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
39+
expect(suggestion?.wordRanges?.length).toBe(2);
40+
expect(suggestion?.wordRanges).toEqual([
41+
{
42+
endColumn: 17,
43+
endIndex: 258,
44+
line: 9,
45+
startColumn: 15,
46+
startIndex: 257,
47+
text: 'db',
48+
},
49+
{
50+
endColumn: 18,
51+
endIndex: 259,
52+
line: 9,
53+
startColumn: 17,
54+
startIndex: 259,
55+
text: '.',
56+
},
57+
]);
4058
});
4159

4260
test('Insert into table ', () => {

test/parser/spark/suggestion/syntaxSuggestion.test.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,33 @@ describe('Spark SQL Syntax Suggestion', () => {
3232
);
3333

3434
expect(suggestion).not.toBeUndefined();
35-
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
35+
expect(suggestion?.wordRanges?.length).toBe(3);
36+
expect(suggestion?.wordRanges).toEqual([
37+
{
38+
text: 'db',
39+
line: 1,
40+
startIndex: 12,
41+
endIndex: 13,
42+
startColumn: 13,
43+
endColumn: 15,
44+
},
45+
{
46+
text: '.',
47+
line: 1,
48+
startIndex: 14,
49+
endIndex: 14,
50+
startColumn: 15,
51+
endColumn: 16,
52+
},
53+
{
54+
text: 'tb',
55+
line: 1,
56+
startIndex: 15,
57+
endIndex: 16,
58+
startColumn: 16,
59+
endColumn: 18,
60+
},
61+
]);
3662
});
3763

3864
test('Select table ', () => {

0 commit comments

Comments
 (0)