diff options
Diffstat (limited to 'test/js/third_party')
-rwxr-xr-x | test/js/third_party/esbuild/bun.lockb | bin | 8425 -> 9601 bytes | |||
-rw-r--r-- | test/js/third_party/esbuild/package.json | 4 | ||||
-rw-r--r-- | test/js/third_party/nodemailer/nodemailer.test.ts | 19 | ||||
-rw-r--r-- | test/js/third_party/nodemailer/package.json | 6 | ||||
-rw-r--r-- | test/js/third_party/nodemailer/process-nodemailer-fixture.js | 20 | ||||
-rw-r--r-- | test/js/third_party/postgres/package.json | 8 | ||||
-rw-r--r-- | test/js/third_party/postgres/postgres.test.ts | 56 | ||||
-rw-r--r-- | test/js/third_party/prisma/package.json | 4 | ||||
-rw-r--r-- | test/js/third_party/prisma/prisma.test.ts | 2 | ||||
-rw-r--r-- | test/js/third_party/socket.io/package.json | 7 | ||||
-rw-r--r-- | test/js/third_party/socket.io/support/util.ts | 1 | ||||
-rw-r--r-- | test/js/third_party/webpack/package.json | 7 | ||||
-rw-r--r-- | test/js/third_party/webpack/test.js | 11 | ||||
-rw-r--r-- | test/js/third_party/webpack/webpack.test.ts | 27 | ||||
-rw-r--r-- | test/js/third_party/webpack/world.js | 3 |
15 files changed, 166 insertions, 9 deletions
diff --git a/test/js/third_party/esbuild/bun.lockb b/test/js/third_party/esbuild/bun.lockb Binary files differindex f46c6aa5d..1fcce3837 100755 --- a/test/js/third_party/esbuild/bun.lockb +++ b/test/js/third_party/esbuild/bun.lockb diff --git a/test/js/third_party/esbuild/package.json b/test/js/third_party/esbuild/package.json index ad6bc55f6..46535bc29 100644 --- a/test/js/third_party/esbuild/package.json +++ b/test/js/third_party/esbuild/package.json @@ -1,6 +1,6 @@ { "type": "module", "dependencies": { - "esbuild": "^0.17.11" + "esbuild": "0.17.11" } -}
\ No newline at end of file +} diff --git a/test/js/third_party/nodemailer/nodemailer.test.ts b/test/js/third_party/nodemailer/nodemailer.test.ts new file mode 100644 index 000000000..36a229524 --- /dev/null +++ b/test/js/third_party/nodemailer/nodemailer.test.ts @@ -0,0 +1,19 @@ +import { test, expect, describe } from "bun:test"; +import { bunRun } from "harness"; +import path from "path"; + +const it = process.env.SMTP_SENDGRID_KEY && process.env.SMTP_SENDGRID_SENDER ? test : test.skip; +describe("nodemailer", () => { + it("basic smtp", async () => { + try { + const info = bunRun(path.join(import.meta.dir, "process-nodemailer-fixture.js"), { + SMTP_SENDGRID_SENDER: process.env.SMTP_SENDGRID_SENDER as string, + SMTP_SENDGRID_KEY: process.env.SMTP_SENDGRID_KEY as string, + }); + expect(info.stdout).toBe("true"); + expect(info.stderr || "").toBe(""); + } catch (err: any) { + expect(err?.message || err).toBe(""); + } + }, 10000); +}); diff --git a/test/js/third_party/nodemailer/package.json b/test/js/third_party/nodemailer/package.json new file mode 100644 index 000000000..08e98074f --- /dev/null +++ b/test/js/third_party/nodemailer/package.json @@ -0,0 +1,6 @@ +{ + "name": "nodemailer", + "dependencies": { + "nodemailer": "6.9.3" + } +} diff --git a/test/js/third_party/nodemailer/process-nodemailer-fixture.js b/test/js/third_party/nodemailer/process-nodemailer-fixture.js new file mode 100644 index 000000000..49ab6a516 --- /dev/null +++ b/test/js/third_party/nodemailer/process-nodemailer-fixture.js @@ -0,0 +1,20 @@ +const nodemailer = require("nodemailer"); +const transporter = nodemailer.createTransport({ + host: "smtp.sendgrid.net", + port: 587, + secure: false, + auth: { + user: "apikey", // generated ethereal user + pass: process.env.SMTP_SENDGRID_KEY, // generated ethereal password + }, +}); + +// send mail with defined transport object +let info = await transporter.sendMail({ + from: process.env.SMTP_SENDGRID_SENDER, // sender address + to: process.env.SMTP_SENDGRID_SENDER, // list of receivers + subject: "Hello ✔", // Subject line + text: "Hello world?", // plain text body + html: "<b>Hello world?</b>", // html body +}); +console.log(typeof info?.messageId === "string"); diff --git a/test/js/third_party/postgres/package.json b/test/js/third_party/postgres/package.json new file mode 100644 index 000000000..90809f48f --- /dev/null +++ b/test/js/third_party/postgres/package.json @@ -0,0 +1,8 @@ +{ + "name": "postgres", + "dependencies": { + "pg": "8.11.1", + "postgres": "3.3.5", + "pg-connection-string": "2.6.1" + } +} diff --git a/test/js/third_party/postgres/postgres.test.ts b/test/js/third_party/postgres/postgres.test.ts new file mode 100644 index 000000000..490192ae7 --- /dev/null +++ b/test/js/third_party/postgres/postgres.test.ts @@ -0,0 +1,56 @@ +import { test, expect, describe } from "bun:test"; +import { Pool } from "pg"; +import { parse } from "pg-connection-string"; +import postgres from "postgres"; + +const CONNECTION_STRING = process.env.TLS_POSTGRES_DATABASE_URL; + +const it = CONNECTION_STRING ? test : test.skip; + +describe("pg", () => { + it("should connect using TLS", async () => { + const pool = new Pool(parse(CONNECTION_STRING as string)); + try { + const { rows } = await pool.query("SELECT version()", []); + const [{ version }] = rows; + + expect(version).toMatch(/PostgreSQL/); + } finally { + pool.end(); + } + }); +}); + +describe("postgres", () => { + it("should connect using TLS", async () => { + const sql = postgres(CONNECTION_STRING as string); + try { + const [{ version }] = await sql`SELECT version()`; + expect(version).toMatch(/PostgreSQL/); + } finally { + sql.end(); + } + }); + + it("should insert, select and delete", async () => { + const sql = postgres(CONNECTION_STRING as string); + try { + await sql`CREATE TABLE IF NOT EXISTS users ( + user_id serial PRIMARY KEY, + username VARCHAR ( 50 ) NOT NULL + );`; + + const [{ user_id, username }] = await sql`insert into users (username) values ('bun') returning *`; + expect(username).toBe("bun"); + + const [{ user_id: user_id2, username: username2 }] = await sql`select * from users where user_id = ${user_id}`; + expect(username2).toBe("bun"); + expect(user_id2).toBe(user_id); + + const [{ username: username3 }] = await sql`delete from users where user_id = ${user_id} returning *`; + expect(username3).toBe("bun"); + } finally { + sql.end(); + } + }); +}); diff --git a/test/js/third_party/prisma/package.json b/test/js/third_party/prisma/package.json index 369bd42ba..ac8694e36 100644 --- a/test/js/third_party/prisma/package.json +++ b/test/js/third_party/prisma/package.json @@ -3,11 +3,11 @@ "module": "index.ts", "type": "module", "devDependencies": { - "bun-types": "^0.6.0", + "bun-types": "0.6.12", "prisma": "4.15.0" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "5.0.0" }, "dependencies": { "@prisma/client": "4.15.0" diff --git a/test/js/third_party/prisma/prisma.test.ts b/test/js/third_party/prisma/prisma.test.ts index abe6f0635..2c87a9fcb 100644 --- a/test/js/third_party/prisma/prisma.test.ts +++ b/test/js/third_party/prisma/prisma.test.ts @@ -10,7 +10,7 @@ function* TestIDGenerator() { } const test_id = TestIDGenerator(); -["sqlite", "postgres", "mongodb"].forEach(async type => { +["sqlite" /*"postgres", "mongodb"*/].forEach(async type => { let Client: typeof PrismaClient; try { diff --git a/test/js/third_party/socket.io/package.json b/test/js/third_party/socket.io/package.json index edeb84845..e54aa3de9 100644 --- a/test/js/third_party/socket.io/package.json +++ b/test/js/third_party/socket.io/package.json @@ -2,9 +2,8 @@ "name": "socket.io", "version": "1.0.0", "dependencies": { - "socket.io": "^4.6.1", - "socket.io-client": "^4.6.1", - "supertest": "^6.1.6", - "uWebSockets.js": "uNetworking/uWebSockets.js#v20.24.0" + "socket.io": "4.6.1", + "socket.io-client": "4.6.1", + "supertest": "6.3.3" } } diff --git a/test/js/third_party/socket.io/support/util.ts b/test/js/third_party/socket.io/support/util.ts index 597b40d65..b5f515568 100644 --- a/test/js/third_party/socket.io/support/util.ts +++ b/test/js/third_party/socket.io/support/util.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import type { Server } from "socket.io"; import request from "supertest"; diff --git a/test/js/third_party/webpack/package.json b/test/js/third_party/webpack/package.json new file mode 100644 index 000000000..fb08bfdc5 --- /dev/null +++ b/test/js/third_party/webpack/package.json @@ -0,0 +1,7 @@ +{ + "name": "webpack-test", + "version": "2.0.0", + "dependencies": { + "webpack": "5.88.0" + } +}
\ No newline at end of file diff --git a/test/js/third_party/webpack/test.js b/test/js/third_party/webpack/test.js new file mode 100644 index 000000000..bfd3e80a1 --- /dev/null +++ b/test/js/third_party/webpack/test.js @@ -0,0 +1,11 @@ +import { world } from "./world.js"; + +function component() { + const element = document.createElement("div"); + + element.innerHTML = "hello " + world(); + + return element; +} + +document.body.appendChild(component()); diff --git a/test/js/third_party/webpack/webpack.test.ts b/test/js/third_party/webpack/webpack.test.ts new file mode 100644 index 000000000..ffc8195c6 --- /dev/null +++ b/test/js/third_party/webpack/webpack.test.ts @@ -0,0 +1,27 @@ +import { bunExe, bunEnv } from "harness"; +import { existsSync, rmdirSync } from "fs"; +import { join } from "path"; + +afterEach(() => { + rmdirSync(join(import.meta.dir, "dist"), { recursive: true }); +}); + +test("webpack works", () => { + Bun.spawnSync({ + cmd: [bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test1/main.js"], + cwd: import.meta.dir, + env: bunEnv, + }); + + expect(existsSync(join(import.meta.dir, "dist", "test1/main.js"))).toBe(true); +}); + +test("webpack --watch works", async () => { + Bun.spawnSync({ + cmd: ["timeout", "3", bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test2/main.js", "--watch"], + cwd: import.meta.dir, + env: bunEnv, + }); + + expect(existsSync(join(import.meta.dir, "dist", "test2/main.js"))).toBe(true); +}); diff --git a/test/js/third_party/webpack/world.js b/test/js/third_party/webpack/world.js new file mode 100644 index 000000000..3fa21bf67 --- /dev/null +++ b/test/js/third_party/webpack/world.js @@ -0,0 +1,3 @@ +export function world() { + return "world"; +} |