Skip to content

Commit d295ae5

Browse files
committed
Tidying tests
1 parent 32f3587 commit d295ae5

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

tests/browser/browser.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,26 @@ import { expect, test, assertType } from 'vitest';
22
import { server } from '@vitest/browser/context';
33
import { neon, Pool, Client, type QueryResult } from '../../dist/npm';
44

5-
const { env } = server.config;
6-
globalThis.process = { env } as any;
7-
8-
const DB_URL = process.env.VITE_NEON_DB_URL!;
5+
const DATABASE_URL = server.config.env.VITE_NEON_DB_URL!;
96

107
test('http query', async () => {
11-
const sql = neon(DB_URL);
8+
const sql = neon(DATABASE_URL);
129
const str = 'fetch';
1310
const fetchResult = await sql`SELECT ${str} AS str`;
1411
assertType<Record<string, unknown>[]>(fetchResult);
1512
expect(fetchResult).toStrictEqual([{ str: 'fetch' }]);
1613
});
1714

1815
test('pool.query() over WebSockets', async () => {
19-
const wsPool = new Pool({ connectionString: DB_URL });
16+
const wsPool = new Pool({ connectionString: DATABASE_URL });
2017
const wsResult = await wsPool.query('SELECT $1::int AS one', [1]);
2118
assertType<QueryResult<any>>(wsResult);
2219
expect(wsResult.rows).toStrictEqual([{ one: 1 }]);
2320
expect((wsResult as any).viaNeonFetch).toBeUndefined();
2421
});
2522

2623
test('client.query()', async () => {
27-
const client = new Client(DB_URL);
24+
const client = new Client(DATABASE_URL);
2825
await client.connect();
2926
const wsResult = await client.query('SELECT $1::int AS one', [1]);
3027
assertType<QueryResult<any>>(wsResult);

tests/cli/http.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
neon,
55
neonConfig,
66
Pool,
7-
type QueryResult,
87
} from '../../dist/npm';
98
import { sampleQueries } from './sampleQueries';
109
import { shimWebSocketIfRequired } from './ws';

tests/cli/sampleQueries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const sampleQueries = (sql: NeonQueryFunction<any, any>) => [
5050
sql`SELECT ${new Uint8Array([65, 66, 67])} AS bytea`,
5151
sql`SELECT ${new Uint8Array(65536).fill(128)} AS bytea`,
5252
sql`SELECT ${Buffer.from([65, 66, 67])} AS bytea`,
53+
sql`SELECT ${1} AS one, ${sql("'raw'")} AS raw, ${'x'} AS x, ${now} AS date`, // multiple types plus raw SQL
5354

5455
// non-tagged-template
5556
sql('SELECT $1::timestamp AS timestampnow', [now]),

tests/cli/ws.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe.each([
155155
process.versions !== undefined &&
156156
parseInt(process.versions.node) >= 19
157157
) {
158-
// subtls test requires SCRAM auth, which requires `crytpo.subtle`, which is only available from Node 19 onwards
158+
// subtls test requires SCRAM auth, which requires `crytpo.subtle`, available from Node 19 onwards
159159
test('client.query() with custom WebSocket proxy and subtls', async () => {
160160
const client = new WsClient(DB_URL);
161161
client.neonConfig.wsProxy = process.env.VITE_WSPROXY!;

tests/cli/ws.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { neonConfig } from '../../dist/npm';
22

33
export async function shimWebSocketIfRequired() {
44
if (typeof WebSocket !== 'function') {
5-
console.info(
6-
'Native WebSocket not found: importing ws for neonConfig.webSocketConstructor',
7-
);
5+
console.info('Importing ws for neonConfig.webSocketConstructor');
86
const { WebSocket } = await import('ws');
97
neonConfig.webSocketConstructor = WebSocket;
108
} else {

0 commit comments

Comments
 (0)