import { applySyntaxColouring } from '../../syntaxColouring/syntaxColouring';
describe('Preparser syntax colouring', () => {
    test('Correctly colours cypher versions', () => {
        const query = 'CYPHER 25 MATCH (m) RETURN m';
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'CYPHER',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 2,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: '25',
                tokenType: 'numberLiteral',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 10,
                    startOffset: 10,
                },
                token: 'MATCH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 16,
                    startOffset: 16,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 17,
                    startOffset: 17,
                },
                token: 'm',
                tokenType: 'variable',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 18,
                    startOffset: 18,
                },
                token: ')',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 20,
                    startOffset: 20,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 27,
                    startOffset: 27,
                },
                token: 'm',
                tokenType: 'variable',
            },
        ]);
    });
    test('Correctly colours CYPHER <setting> = <setting-value> options', () => {
        const query = 'CYPHER runtime = slotted RETURN ""';
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'CYPHER',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: 'runtime',
                tokenType: 'setting',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: '=',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 17,
                    startOffset: 17,
                },
                token: 'slotted',
                tokenType: 'settingValue',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 25,
                    startOffset: 25,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 2,
                position: {
                    line: 0,
                    startCharacter: 32,
                    startOffset: 32,
                },
                token: '""',
                tokenType: 'stringLiteral',
            },
        ]);
    });
    test('Correctly colours PROFILE', () => {
        const query = 'PROFILE MATCH (n) RETURN n';
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'PROFILE',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 8,
                    startOffset: 8,
                },
                token: 'MATCH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 14,
                    startOffset: 14,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: 'n',
                tokenType: 'variable',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 16,
                    startOffset: 16,
                },
                token: ')',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 18,
                    startOffset: 18,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 25,
                    startOffset: 25,
                },
                token: 'n',
                tokenType: 'variable',
            },
        ]);
    });
    test('Correctly colours EXPLAIN', () => {
        const query = 'EXPLAIN MATCH (n) RETURN n';
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'EXPLAIN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 8,
                    startOffset: 8,
                },
                token: 'MATCH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 14,
                    startOffset: 14,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: 'n',
                tokenType: 'variable',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 16,
                    startOffset: 16,
                },
                token: ')',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 18,
                    startOffset: 18,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 25,
                    startOffset: 25,
                },
                token: 'n',
                tokenType: 'variable',
            },
        ]);
    });
    test('Correctly colours EXPLAIN and PROFILE in different statements', () => {
        const query = 'EXPLAIN MATCH (n) RETURN n; PROFILE MATCH (m) RETURN m';
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'EXPLAIN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 8,
                    startOffset: 8,
                },
                token: 'MATCH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 14,
                    startOffset: 14,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: 'n',
                tokenType: 'variable',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 16,
                    startOffset: 16,
                },
                token: ')',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 18,
                    startOffset: 18,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 25,
                    startOffset: 25,
                },
                token: 'n',
                tokenType: 'variable',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 26,
                    startOffset: 26,
                },
                token: ';',
                tokenType: 'punctuation',
            },
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 28,
                    startOffset: 28,
                },
                token: 'PROFILE',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 36,
                    startOffset: 36,
                },
                token: 'MATCH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 42,
                    startOffset: 42,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 43,
                    startOffset: 43,
                },
                token: 'm',
                tokenType: 'variable',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 44,
                    startOffset: 44,
                },
                token: ')',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 46,
                    startOffset: 46,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 53,
                    startOffset: 53,
                },
                token: 'm',
                tokenType: 'variable',
            },
        ]);
    });
    test('Correctly colours console commands used as variables or labels', () => {
        const query = `CREATE (n:clear {use: 0})
WITH $param AS map
RETURN map.propertyKey`;
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'CREATE',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 8,
                    startOffset: 8,
                },
                token: 'n',
                tokenType: 'variable',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 9,
                    startOffset: 9,
                },
                token: ':',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 10,
                    startOffset: 10,
                },
                token: 'clear',
                tokenType: 'label',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'curly',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 16,
                    startOffset: 16,
                },
                token: '{',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 3,
                position: {
                    line: 0,
                    startCharacter: 17,
                    startOffset: 17,
                },
                token: 'use',
                tokenType: 'property',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 20,
                    startOffset: 20,
                },
                token: ':',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 22,
                    startOffset: 22,
                },
                token: '0',
                tokenType: 'numberLiteral',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'curly',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 23,
                    startOffset: 23,
                },
                token: '}',
                tokenType: 'bracket',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 24,
                    startOffset: 24,
                },
                token: ')',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 4,
                position: {
                    line: 1,
                    startCharacter: 0,
                    startOffset: 26,
                },
                token: 'WITH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 1,
                    startCharacter: 5,
                    startOffset: 31,
                },
                token: '$',
                tokenType: 'paramDollar',
            },
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 1,
                    startCharacter: 6,
                    startOffset: 32,
                },
                token: 'param',
                tokenType: 'paramValue',
            },
            {
                bracketInfo: undefined,
                length: 2,
                position: {
                    line: 1,
                    startCharacter: 12,
                    startOffset: 38,
                },
                token: 'AS',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 3,
                position: {
                    line: 1,
                    startCharacter: 15,
                    startOffset: 41,
                },
                token: 'map',
                tokenType: 'variable',
            },
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 2,
                    startCharacter: 0,
                    startOffset: 45,
                },
                token: 'RETURN',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 3,
                position: {
                    line: 2,
                    startCharacter: 7,
                    startOffset: 52,
                },
                token: 'map',
                tokenType: 'variable',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 2,
                    startCharacter: 10,
                    startOffset: 55,
                },
                token: '.',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 11,
                position: {
                    line: 2,
                    startCharacter: 11,
                    startOffset: 56,
                },
                token: 'propertyKey',
                tokenType: 'property',
            },
        ]);
    });
    test('Correctly colours preparser options including unfinished comments', () => {
        const query = `CYPHER runtime = /*some unfinished comment
    slotted`;
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'CYPHER',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: 'runtime',
                tokenType: 'setting',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: '=',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 25,
                position: {
                    line: 0,
                    startCharacter: 17,
                    startOffset: 17,
                },
                token: '/*some unfinished comment',
                tokenType: 'comment',
            },
            {
                bracketInfo: undefined,
                length: 11,
                position: {
                    line: 1,
                    startCharacter: 0,
                    startOffset: 43,
                },
                token: '    slotted',
                tokenType: 'comment',
            },
        ]);
    });
    test('Correctly colours preparser options including unfinished backticked elements', () => {
        const query = `CYPHER runtime = \`some unfinished 
    backticked element
    `;
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'CYPHER',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: 'runtime',
                tokenType: 'setting',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: '=',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 17,
                position: {
                    line: 0,
                    startCharacter: 17,
                    startOffset: 17,
                },
                token: '`some unfinished ',
                tokenType: 'symbolicName',
            },
            {
                bracketInfo: undefined,
                length: 22,
                position: {
                    line: 1,
                    startCharacter: 0,
                    startOffset: 35,
                },
                token: '    backticked element',
                tokenType: 'symbolicName',
            },
            {
                bracketInfo: undefined,
                length: 4,
                position: {
                    line: 2,
                    startCharacter: 0,
                    startOffset: 58,
                },
                token: '    ',
                tokenType: 'symbolicName',
            },
        ]);
    });
    test('Correctly colours preparser options including unfinished strings', () => {
        const query = `CYPHER runtime = "some unfinished 
    string
    `;
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 6,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'CYPHER',
                tokenType: 'keyword',
            },
            {
                bracketInfo: undefined,
                length: 7,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: 'runtime',
                tokenType: 'setting',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 15,
                    startOffset: 15,
                },
                token: '=',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 17,
                position: {
                    line: 0,
                    startCharacter: 17,
                    startOffset: 17,
                },
                token: `"some unfinished `,
                tokenType: 'stringLiteral',
            },
            {
                bracketInfo: undefined,
                length: 10,
                position: {
                    line: 1,
                    startCharacter: 0,
                    startOffset: 35,
                },
                token: '    string',
                tokenType: 'stringLiteral',
            },
            {
                bracketInfo: undefined,
                length: 4,
                position: {
                    line: 2,
                    startCharacter: 0,
                    startOffset: 46,
                },
                token: '    ',
                tokenType: 'stringLiteral',
            },
        ]);
    });
    test('Correctly colours strings in wrong places', () => {
        const query = `MATCH (n: "foo bar 

      adfsa
      asfds`;
        expect(applySyntaxColouring(query)).toEqual([
            {
                bracketInfo: undefined,
                length: 5,
                position: {
                    line: 0,
                    startCharacter: 0,
                    startOffset: 0,
                },
                token: 'MATCH',
                tokenType: 'keyword',
            },
            {
                bracketInfo: {
                    bracketLevel: 0,
                    bracketType: 'parenthesis',
                },
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 6,
                    startOffset: 6,
                },
                token: '(',
                tokenType: 'bracket',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 7,
                    startOffset: 7,
                },
                token: 'n',
                tokenType: 'variable',
            },
            {
                bracketInfo: undefined,
                length: 1,
                position: {
                    line: 0,
                    startCharacter: 8,
                    startOffset: 8,
                },
                token: ':',
                tokenType: 'operator',
            },
            {
                bracketInfo: undefined,
                length: 9,
                position: {
                    line: 0,
                    startCharacter: 10,
                    startOffset: 10,
                },
                token: `"foo bar `,
                tokenType: 'stringLiteral',
            },
            {
                bracketInfo: undefined,
                length: 11,
                position: {
                    line: 2,
                    startCharacter: 0,
                    startOffset: 21,
                },
                token: '      adfsa',
                tokenType: 'stringLiteral',
            },
            {
                bracketInfo: undefined,
                length: 11,
                position: {
                    line: 3,
                    startCharacter: 0,
                    startOffset: 33,
                },
                token: '      asfds',
                tokenType: 'stringLiteral',
            },
        ]);
    });
});
//# sourceMappingURL=preparser.test.js.map