Skip to content

Commit 6ab0c46

Browse files
authored
More tests & exports from pg-protocol (#3436)
1 parent ad3e603 commit 6ab0c46

File tree

6 files changed

+34
-3
lines changed

6 files changed

+34
-3
lines changed

packages/pg-esm-test/common-js-imports.test.cjs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ const assert = require('node:assert')
22
const test = require('node:test')
33
const { describe, it } = test
44

5-
const paths = ['pg', 'pg/lib/index.js', 'pg/lib/connection-parameters.js']
5+
const paths = [
6+
'pg',
7+
'pg/lib/index.js',
8+
'pg/lib/connection-parameters.js',
9+
'pg-protocol/dist/messages.js',
10+
'pg-native/lib/build-result.js',
11+
]
612
for (const path of paths) {
713
describe(`importing ${path}`, () => {
814
it('works with require', () => {

packages/pg-esm-test/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"pg-cursor": "^2.14.1",
2020
"pg-native": "^3.4.0",
2121
"pg-pool": "^3.9.1",
22-
"pg-query-stream": "^4.9.1"
22+
"pg-query-stream": "^4.9.1",
23+
"pg-protocol": "^1.9.0"
2324
},
2425
"author": "Brian M. Carlson <brian.m.carlson@gmail.com>",
2526
"license": "MIT"
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import protocol, { NoticeMessage, DatabaseError } from 'pg-protocol/dist/messages.js'
2+
import { describe, it } from 'node:test'
3+
import { strict as assert } from 'node:assert'
4+
5+
describe('pg-protocol', () => {
6+
it('should export database error', () => {
7+
assert.ok(DatabaseError)
8+
})
9+
it('should export protocol', () => {
10+
assert.ok(protocol)
11+
assert.ok(protocol.noData)
12+
assert.ok(protocol.parseComplete)
13+
assert.ok(protocol.NoticeMessage)
14+
})
15+
it('should export NoticeMessage from file in dist folder', () => {
16+
assert.ok(NoticeMessage)
17+
})
18+
})

packages/pg-native/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
},
5050
"files": [
5151
"index.js",
52+
"lib",
5253
"esm"
5354
]
5455
}

packages/pg-protocol/esm/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ESM wrapper for pg-protocol
2-
import protocol from '../dist/index.js'
2+
import * as protocol from '../dist/index.js'
33

44
// Re-export all the properties
55
export const DatabaseError = protocol.DatabaseError

packages/pg-protocol/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"import": "./esm/index.js",
1010
"require": "./dist/index.js",
1111
"default": "./dist/index.js"
12+
},
13+
"./dist/*": {
14+
"import": "./dist/*",
15+
"require": "./dist/*",
16+
"default": "./dist/*"
1217
}
1318
},
1419
"license": "MIT",

0 commit comments

Comments
 (0)