Skip to content

Commit 4fe43b1

Browse files
simplify tests
1 parent 9fb4375 commit 4fe43b1

1 file changed

Lines changed: 45 additions & 118 deletions

File tree

test/bigquery.test.ts

Lines changed: 45 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -168,126 +168,53 @@ describe('BigQueryFormatter', () => {
168168
});
169169

170170
it('supports create view optional arguments', () => {
171-
expect(
172-
format(`
173-
CREATE OR REPLACE VIEW my_dataset.my_view AS (
174-
SELECT t1.col1, t1.col2 FROM my_dataset.my_table)`)
175-
).toBe(dedent`
176-
CREATE OR REPLACE VIEW
177-
my_dataset.my_view AS (
178-
SELECT
179-
t1.col1,
180-
t1.col2
181-
FROM
182-
my_dataset.my_table
183-
)
184-
`);
185-
186-
expect(
187-
format(`
188-
CREATE VIEW IF NOT EXISTS my_dataset.my_view AS (
189-
SELECT t1.col1, t1.col2 FROM my_dataset.my_table)`)
190-
).toBe(dedent`
191-
CREATE VIEW IF NOT EXISTS
192-
my_dataset.my_view AS (
193-
SELECT
194-
t1.col1,
195-
t1.col2
196-
FROM
197-
my_dataset.my_table
198-
)
199-
`);
171+
const createViewVariations = [
172+
'CREATE VIEW',
173+
'CREATE OR REPLACE VIEW',
174+
'CREATE VIEW IF NOT EXISTS',
175+
];
176+
177+
createViewVariations.forEach((createViewVariation: string) => {
178+
expect(
179+
format(`
180+
${createViewVariation} my_dataset.my_view AS (
181+
SELECT t1.col1, t1.col2 FROM my_dataset.my_table)`)
182+
).toBe(dedent`
183+
${createViewVariation}
184+
my_dataset.my_view AS (
185+
SELECT
186+
t1.col1,
187+
t1.col2
188+
FROM
189+
my_dataset.my_table
190+
)
191+
`);
192+
});
200193
});
201194

202195
it('supports create table optional arguments', () => {
203-
expect(
204-
format(`
205-
CREATE TABLE mydataset.newtable (
206-
a INT64 NOT NULL
207-
)`)
208-
).toBe(dedent`
209-
CREATE TABLE
210-
mydataset.newtable (a INT64 NOT NULL)
211-
`);
212-
213-
expect(
214-
format(`
215-
CREATE TABLE IF NOT EXISTS mydataset.newtable (
216-
a INT64 NOT NULL
217-
)`)
218-
).toBe(dedent`
219-
CREATE TABLE IF NOT EXISTS
220-
mydataset.newtable (a INT64 NOT NULL)
221-
`);
222-
223-
expect(
224-
format(`
225-
CREATE TEMP TABLE mydataset.newtable (
226-
a INT64 NOT NULL
227-
)`)
228-
).toBe(dedent`
229-
CREATE TEMP TABLE
230-
mydataset.newtable (a INT64 NOT NULL)
231-
`);
232-
233-
expect(
234-
format(`
235-
CREATE TEMP TABLE IF NOT EXISTS mydataset.newtable (
236-
a INT64 NOT NULL
237-
)`)
238-
).toBe(dedent`
239-
CREATE TEMP TABLE IF NOT EXISTS
240-
mydataset.newtable (a INT64 NOT NULL)
241-
`);
242-
243-
expect(
244-
format(`
245-
CREATE TEMPORARY TABLE mydataset.newtable (
246-
a INT64 NOT NULL
247-
)`)
248-
).toBe(dedent`
249-
CREATE TEMPORARY TABLE
250-
mydataset.newtable (a INT64 NOT NULL)
251-
`);
252-
253-
expect(
254-
format(`
255-
CREATE TEMPORARY TABLE IF NOT EXISTS mydataset.newtable (
256-
a INT64 NOT NULL
257-
)`)
258-
).toBe(dedent`
259-
CREATE TEMPORARY TABLE IF NOT EXISTS
260-
mydataset.newtable (a INT64 NOT NULL)
261-
`);
262-
263-
expect(
264-
format(`
265-
CREATE OR REPLACE TABLE mydataset.newtable (
266-
a INT64 NOT NULL
267-
)`)
268-
).toBe(dedent`
269-
CREATE OR REPLACE TABLE
270-
mydataset.newtable (a INT64 NOT NULL)
271-
`);
272-
273-
expect(
274-
format(`
275-
CREATE OR REPLACE TEMP TABLE mydataset.newtable (
276-
a INT64 NOT NULL
277-
)`)
278-
).toBe(dedent`
279-
CREATE OR REPLACE TEMP TABLE
280-
mydataset.newtable (a INT64 NOT NULL)
281-
`);
282-
283-
expect(
284-
format(`
285-
CREATE OR REPLACE TEMPORARY TABLE mydataset.newtable (
286-
a INT64 NOT NULL
287-
)`)
288-
).toBe(dedent`
289-
CREATE OR REPLACE TEMPORARY TABLE
290-
mydataset.newtable (a INT64 NOT NULL)
291-
`);
196+
const createTableVariations = [
197+
'CREATE TABLE',
198+
'CREATE TABLE IF NOT EXISTS',
199+
'CREATE TEMP TABLE',
200+
'CREATE TEMP TABLE IF NOT EXISTS',
201+
'CREATE TEMPORARY TABLE',
202+
'CREATE TEMPORARY TABLE IF NOT EXISTS',
203+
'CREATE OR REPLACE TABLE',
204+
'CREATE OR REPLACE TEMP TABLE',
205+
'CREATE OR REPLACE TEMPORARY TABLE',
206+
];
207+
208+
createTableVariations.forEach((createTableVariation: string) => {
209+
expect(
210+
format(`
211+
${createTableVariation} mydataset.newtable (
212+
a INT64 NOT NULL
213+
)`)
214+
).toBe(dedent`
215+
${createTableVariation}
216+
mydataset.newtable (a INT64 NOT NULL)
217+
`);
218+
});
292219
});
293220
});

0 commit comments

Comments
 (0)