Add tests for connection-string and fix cloudflare module type and esm compat

This commit is contained in:
Brian Carlson 2025-04-21 13:51:46 -05:00
parent 0cb8fd4216
commit 0a0e298e06
11 changed files with 33 additions and 33 deletions

View File

@ -1,6 +0,0 @@
// ESM wrapper for pg-cloudflare
import module from '../dist/empty.js'
// Re-export any named exports and the default
export const CloudflareSocket = module.CloudflareSocket
export default module

View File

@ -1,6 +0,0 @@
// ESM wrapper for pg-cloudflare in Cloudflare Workers
import module from '../dist/index.js'
// Re-export CloudflareSocket and the default
export const CloudflareSocket = module.CloudflareSocket
export default module

View File

@ -4,23 +4,12 @@
"description": "A socket implementation that can run on Cloudflare Workers using native TCP connections.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"license": "MIT",
"devDependencies": {
"ts-node": "^8.5.4",
"typescript": "^4.0.3"
},
"exports": {
".": {
"import": "./esm/worker.js",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"./worker": {
"import": "./esm/worker.js",
"require": "./dist/index.js",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",

View File

@ -3,6 +3,5 @@ import connectionString from '../index.js'
// Re-export the parse function
export const parse = connectionString.parse
// Re-export the default
export default connectionString
export const toClientConfig = connectionString.toClientConfig
export const parseIntoClientConfig = connectionString.parseIntoClientConfig

View File

@ -7,7 +7,7 @@
"exports": {
".": {
"types": "./index.d.ts",
"import": "./esm/index.js",
"import": "./esm/index.mjs",
"require": "./index.js",
"default": "./index.js"
}

View File

@ -13,10 +13,11 @@
"esm",
"test"
],
"dependencies": {
"devDependencies": {
"pg": "^8.14.1",
"pg-pool": "^3.8.0",
"pg-native": "^3.3.0"
"pg-native": "^3.3.0",
"pg-cloudflare": "^1.1.1"
},
"author": "Brian M. Carlson <brian.m.carlson@gmail.com>",
"license": "MIT"

View File

@ -0,0 +1,9 @@
import assert from 'node:assert'
import { describe, it } from 'node:test'
import { CloudflareSocket } from 'pg-cloudflare'
describe('pg-pool', () => {
it('should export CloudflareSocket constructor', () => {
assert.ok(new CloudflareSocket())
})
})

View File

@ -0,0 +1,17 @@
import assert from 'node:assert'
import { describe, it } from 'node:test'
import { parse, toClientConfig, parseIntoClientConfig } from 'pg-connection-string'
describe('pg-connection-string', () => {
it('should export parse function', () => {
assert.strictEqual(typeof parse, 'function')
})
it('should export toClientConfig function', () => {
assert.strictEqual(typeof toClientConfig, 'function')
})
it('should export parseIntoClientConfig function', () => {
assert.strictEqual(typeof parseIntoClientConfig, 'function')
})
})

View File

@ -1,4 +1,3 @@
// test/my-module.test.js
import assert from 'node:assert'
import { describe, it } from 'node:test'
import Client from 'pg-native'

View File

@ -1,4 +1,3 @@
// test/my-module.test.js
import assert from 'node:assert'
import { describe, it } from 'node:test'
import Pool from 'pg-pool'

View File

@ -1,4 +1,3 @@
// test/my-module.test.js
import assert from 'node:assert'
import { describe, it } from 'node:test'
import pg, { Client, Pool } from 'pg'