Skip to content

Commit

Permalink
test: add tests for #2838, #2836
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 7, 2024
1 parent 4307202 commit 03bdd2d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/fixture/files/sql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--
1 change: 1 addition & 0 deletions test/fixture/files/sqlts.sql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "--\n";
12 changes: 12 additions & 0 deletions test/fixture/routes/raw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-ignore
import sql from "../files/sql.sql";

// https://github.com/nitrojs/nitro/issues/2836
import sqlts from "../files/sqlts.sql";

export default defineEventHandler(async () => {
return {
sql,
sqlts,
};
});
8 changes: 8 additions & 0 deletions test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,12 @@ export function testNitro(
expect(data).toBe(ctx.isDev ? "dev env" : "prod env");
});
});

it("raw imports", async () => {
const { data } = await callHandler({ url: "/raw" });
expect(data).toMatchObject({

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/aws-lambda.test.ts > nitro:preset:aws-lambda > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/aws-lambda.test.ts > nitro:preset:aws-lambda > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/cloudflare-module-legacy.test.ts > nitro:preset:cloudflare-module > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/cloudflare-module.test.ts > nitro:preset:cloudflare-module > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/cloudflare-worker.test.ts > nitro:preset:cloudflare-worker > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/netlify-legacy.test.ts > nitro:preset:netlify-legacy > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/netlify.test.ts > nitro:preset:netlify > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/node.test.ts > nitro:preset:node-listener > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18

Check failure on line 784 in test/tests.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

test/presets/vercel.test.ts > nitro:preset:vercel > raw imports

AssertionError: expected { sql: '--\r\n', sqlts: '--\n' } to match object { sql: '--\n', sqlts: '--\n' } - Expected + Received Object { - "sql": "-- + "sql": "-- ", "sqlts": "-- ", } ❯ test/tests.ts:784:18
sql: "--\n",
sqlts: "--\n",
});
});
}

0 comments on commit 03bdd2d

Please sign in to comment.