From ca3f3d9163bd340ee07cf039df331cf2fa089351 Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Mon, 13 Nov 2023 17:09:42 +0100 Subject: [PATCH] Add additional tests for array identifier conversions --- test/features/arrayAndMapAccessors.ts | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/features/arrayAndMapAccessors.ts b/test/features/arrayAndMapAccessors.ts index dc6c80bd67..756d0fb4c8 100644 --- a/test/features/arrayAndMapAccessors.ts +++ b/test/features/arrayAndMapAccessors.ts @@ -23,6 +23,18 @@ export default function supportsArrayAndMapAccessors(format: FormatFn) { `); }); + it('supports square brackets for map lookup - uppercase', () => { + const result = format(`SELECT Alpha['a'], Beta['gamma'].zeTa, yotA['foo.bar-baz'];`, { + identifierCase: 'upper', + }); + expect(result).toBe(dedent` + SELECT + ALPHA['a'], + BETA['gamma'].ZETA, + YOTA['foo.bar-baz']; + `); + }); + it('supports namespaced array identifiers', () => { const result = format(`SELECT foo.coalesce['blah'];`); expect(result).toBe(dedent` @@ -47,6 +59,22 @@ export default function supportsArrayAndMapAccessors(format: FormatFn) { `); }); + it('supports namespaced array identifiers in uppercase', () => { + const result = format(`SELECT Foo.Coalesce['Blah'];`, { identifierCase: 'upper' }); + expect(result).toBe(dedent` + SELECT + FOO.COALESCE['Blah']; + `); + }); + + it('supports namespaced array identifiers in lowercase', () => { + const result = format(`SELECT Foo.Coalesce['Blah'];`, { identifierCase: 'lower' }); + expect(result).toBe(dedent` + SELECT + foo.coalesce['Blah']; + `); + }); + it('formats namespaced array accessor with comment in-between in uppercase', () => { const result = format(`SELECT foo./* comment */arr[1];`, { identifierCase: 'upper' }); expect(result).toBe(dedent`