import dedent from 'dedent-js';
import { NewlineMode } from '../../src/types';

/**
 * Tests support for CREATE TABLE syntax
 * @param {string} language
 * @param {Function} format
 */
export default function supportsCreateTable(language, format) {
  it('formats short CREATE TABLE', () => {
    expect(
      format('CREATE TABLE tbl (a INT PRIMARY KEY, b TEXT);', {
        newline: NewlineMode.never,
      })
    ).toBe('CREATE TABLE tbl (a INT PRIMARY KEY, b TEXT);');
  });

  // The decision to place it to multiple lines is made based on the length of text inside braces
  // ignoring the whitespace. (Which is not quite right :P)
  it('formats long CREATE TABLE', () => {
    expect(
      format('CREATE TABLE tbl (a INT PRIMARY KEY, b TEXT, c INT NOT NULL, doggie INT NOT NULL);')
    ).toBe(dedent`
      CREATE TABLE
        tbl (
          a INT PRIMARY KEY,
          b TEXT,
          c INT NOT NULL,
          doggie INT NOT NULL
        );
    `);
  });
}

@@ -28,55 +28,8 @@
 js';
-%0Aimport %7B NewlineMode %7D from '../../src/types';
 %0A%0A/*
@@ -241,39 +241,32 @@
 =%3E %7B%0A    expect(
-%0A      
 format('CREATE T
@@ -307,69 +307,30 @@
 T);'
-, %7B%0A        newline: NewlineMode.never,%0A      %7D)%0A    ).toBe('
+)).toBe(dedent%60%0A      
 CREA
@@ -329,32 +329,40 @@
     CREATE TABLE
+%0A       
  tbl (a INT PRIM
@@ -378,17 +378,22 @@
 b TEXT);
-'
+%0A    %60
 );%0A  %7D);

Remove newline option from createTable test