|
| 1 | +import {prepareQueryWithPragmas} from '../../../../../store/reducers/query/utils'; |
| 2 | + |
| 3 | +describe('TablePreview - Pragma Integration', () => { |
| 4 | + test('should correctly prepare query with pragmas for table preview', () => { |
| 5 | + const baseQuery = 'select * from `test-table` limit 101'; |
| 6 | + const pragmas = 'PRAGMA OrderedColumns;'; |
| 7 | + |
| 8 | + const result = prepareQueryWithPragmas(baseQuery, pragmas); |
| 9 | + |
| 10 | + expect(result).toBe('PRAGMA OrderedColumns;\n\nselect * from `test-table` limit 101'); |
| 11 | + }); |
| 12 | + |
| 13 | + test('should handle empty pragmas correctly in table preview', () => { |
| 14 | + const baseQuery = 'select * from `test-table` limit 101'; |
| 15 | + const pragmas = ''; |
| 16 | + |
| 17 | + const result = prepareQueryWithPragmas(baseQuery, pragmas); |
| 18 | + |
| 19 | + expect(result).toBe('select * from `test-table` limit 101'); |
| 20 | + }); |
| 21 | + |
| 22 | + test('should handle multiple pragmas correctly in table preview', () => { |
| 23 | + const baseQuery = 'select * from `test-table` limit 101'; |
| 24 | + const pragmas = 'PRAGMA OrderedColumns;\nPRAGMA AnsiOptionalAS;'; |
| 25 | + |
| 26 | + const result = prepareQueryWithPragmas(baseQuery, pragmas); |
| 27 | + |
| 28 | + expect(result).toBe( |
| 29 | + 'PRAGMA OrderedColumns;\nPRAGMA AnsiOptionalAS;\n\nselect * from `test-table` limit 101', |
| 30 | + ); |
| 31 | + }); |
| 32 | + |
| 33 | + test('should handle pragmas without semicolon correctly in table preview', () => { |
| 34 | + const baseQuery = 'select * from `test-table` limit 101'; |
| 35 | + const pragmas = 'PRAGMA OrderedColumns'; |
| 36 | + |
| 37 | + const result = prepareQueryWithPragmas(baseQuery, pragmas); |
| 38 | + |
| 39 | + expect(result).toBe('PRAGMA OrderedColumns;\n\nselect * from `test-table` limit 101'); |
| 40 | + }); |
| 41 | +}); |
0 commit comments