Skip to content

Commit

Permalink
Add additional tests for array identifier conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjorgensen committed Nov 13, 2023
1 parent 0bb7d21 commit ca3f3d9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/features/arrayAndMapAccessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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`
Expand Down

0 comments on commit ca3f3d9

Please sign in to comment.