<commit_before>import sqlFormatter from "./../src/sqlFormatter";

/**
 * Core tests for all SQL formatters
 * @param {String} language
 */
export default function behavesLikeSqlFormatter(language) {
    it("uses given indent config for indention", function () {
        const result = sqlFormatter.format(
            "SELECT count(*),Column1 FROM Table1;",
            { language, indent: "    " }
        );

        expect(result).toBe(
            "SELECT\n" +
            "    count(*),\n" +
            "    Column1\n" +
            "FROM\n" +
            "    Table1;\n"
        );
    });

    function format(query) {
        return sqlFormatter.format(query, {language});
    }

    it("formats simple SET SCHEMA queries", function() {
        const result = format("SET SCHEMA tetrisdb; SET CURRENT SCHEMA bingodb;");
        expect(result).toBe(
            "SET SCHEMA\n" +
            "  tetrisdb;\n" +
            "SET CURRENT SCHEMA\n" +
            "  bingodb;\n"
        );
    });

    it("formats simple SELECT query", function() {
        const result = format("SELECT count(*),Column1 FROM Table1;");
        expect(result).toBe(
            "SELECT\n" +
            "  count(*),\n" +
            "  Column1\n" +
            "FROM\n" +
            "  Table1;\n"
        );
    });

    it("formats complex SELECT", function() {
        const result = format(
            "SELECT DISTINCT name, ROUND(age/7) field1, 18 + 20 AS field2, 'some string' FROM foo;"
        );
        expect(result).toBe(
            "SELECT\n" +
            "  DISTINCT name,\n" +
            "  ROUND(age / 7) field1,\n" +
            "  18 + 20 AS field2,\n" +
            "  'some string'\n" +
            "FROM\n" +
            "  foo;\n"
        );
    });

    it("formats SELECT with complex WHERE", function () {
        const result = format(
            "SELECT * FROM foo WHERE Column1 = 'testing' " +
            "AND ( (Column2 = Column3 OR Column4 >= NOW()) );"
        );
        expect(result).toBe(
            "SELECT\n" +
            "  *\n" +
            "FROM\n" +
            "  foo\n" +
            "WHERE\n" +
            "  Column1 = 'testing'\n" +
            "  AND (\n" +
            "    (\n" +
            "      Column2 = Column3\n" +
            "      OR Column4 >= NOW()\n" +
            "    )\n" +
            "  );\n"
        );
    });

    it("formats SELECT with complex WHERE with national characters (MSSQL)", function () {
        const result = format(
            "SELECT * FROM foo WHERE Column1 = N'testing' " +
            "AND ( (Column2 = Column3 OR Column4 >= NOW()) );"
        );
        expect(result).toBe(
            "SELECT\n" +
            "  *\n" +
            "FROM\n" +
            "  foo\n" +
            "WHERE\n" +
            "  Column1 = N'testing'\n" +
            "  AND (\n" +
            "    (\n" +
            "      Column2 = Column3\n" +
            "      OR Column4 >= NOW()\n" +
            "    )\n" +
            "  );\n"
        );
    });

    it("formats SELECT with toplevel reserved words", function() {
        const result = format(
            "SELECT * FROM foo WHERE name = 'John' GROUP BY some_column " +
            "HAVING column > 10 ORDER BY other_column LIMIT 5;"
        );<commit_msg>Fixed linting issues<commit_after>import sqlFormatter from "./../src/sqlFormatter";

/**
 * Core tests for all SQL formatters
 * @param {String} language
 */
export default function behavesLikeSqlFormatter(language) {
    it("uses given indent config for indention", function() {
        const result = sqlFormatter.format(
            "SELECT count(*),Column1 FROM Table1;",
            { language, indent: "    " }
        );

        expect(result).toBe(
            "SELECT\n" +
            "    count(*),\n" +
            "    Column1\n" +
            "FROM\n" +
            "    Table1;\n"
        );
    });

    function format(query) {
        return sqlFormatter.format(query, {language});
    }

    it("formats simple SET SCHEMA queries", function() {
        const result = format("SET SCHEMA tetrisdb; SET CURRENT SCHEMA bingodb;");
        expect(result).toBe(
            "SET SCHEMA\n" +
            "  tetrisdb;\n" +
            "SET CURRENT SCHEMA\n" +
            "  bingodb;\n"
        );
    });

    it("formats simple SELECT query", function() {
        const result = format("SELECT count(*),Column1 FROM Table1;");
        expect(result).toBe(
            "SELECT\n" +
            "  count(*),\n" +
            "  Column1\n" +
            "FROM\n" +
            "  Table1;\n"
        );
    });

    it("formats complex SELECT", function() {
        const result = format(
            "SELECT DISTINCT name, ROUND(age/7) field1, 18 + 20 AS field2, 'some string' FROM foo;"
        );
        expect(result).toBe(
            "SELECT\n" +
            "  DISTINCT name,\n" +
            "  ROUND(age / 7) field1,\n" +
            "  18 + 20 AS field2,\n" +
            "  'some string'\n" +
            "FROM\n" +
            "  foo;\n"
        );
    });

    it("formats SELECT with complex WHERE", function() {
        const result = format(
            "SELECT * FROM foo WHERE Column1 = 'testing' " +
            "AND ( (Column2 = Column3 OR Column4 >= NOW()) );"
        );
        expect(result).toBe(
            "SELECT\n" +
            "  *\n" +
            "FROM\n" +
            "  foo\n" +
            "WHERE\n" +
            "  Column1 = 'testing'\n" +
            "  AND (\n" +
            "    (\n" +
            "      Column2 = Column3\n" +
            "      OR Column4 >= NOW()\n" +
            "    )\n" +
            "  );\n"
        );
    });

    it("formats SELECT with complex WHERE with national characters (MSSQL)", function() {
        const result = format(
            "SELECT * FROM foo WHERE Column1 = N'testing' " +
            "AND ( (Column2 = Column3 OR Column4 >= NOW()) );"
        );
        expect(result).toBe(
            "SELECT\n" +
            "  *\n" +
            "FROM\n" +
            "  foo\n" +
            "WHERE\n" +
            "  Column1 = N'testing'\n" +
            "  AND (\n" +
            "    (\n" +
            "      Column2 = Column3\n" +
            "      OR Column4 >= NOW()\n" +
            "    )\n" +
            "  );\n"
        );
    });

    it("formats SELECT with toplevel reserved words", function() {
        const result = format(
            "SELECT * FROM foo WHERE name = 'John' GROUP BY some_column " +
            "HAVING column > 10 ORDER BY other_column LIMIT 5;"
        );
{'fraction_non_alphanumeric': 0.146163215590743, 'fraction_numerical': 0.012484774665042631, 'mean_word_length': 1.3146582100070472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '795912', 'n_tokens_mistral': 2045, 'n_tokens_neox': 1946, 'n_words': 458}