Skip to content

Commit eb9897a

Browse files
committed
Add deno test
1 parent ee556a6 commit eb9897a

File tree

6 files changed

+68
-8
lines changed

6 files changed

+68
-8
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test": "jest",
1111
"test::watch": "jest --watch",
1212
"test::unit": "npm run test",
13-
"test::deno": "deno test --allow-none ./test/deno/",
13+
"test::deno": "deno test --allow-sys ./test/deno/",
1414
"predocs": "npm run build && npm run build::es6",
1515
"docs": "esdoc -c esdoc.json",
1616
"prepare": "npm run build",

packages/core/src/internal/bolt-agent/deno/bolt-agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function fromVersion (version: string): string {
2626
//@ts-ignore
2727
const NODE_V8_VERSION = Deno.version.v8
2828
//@ts-ignore
29-
const OS_NAME_VERSION = `${Deno.build.os} ${Deno.osRelease}`
29+
const OS_NAME_VERSION = `${Deno.build.os} ${Deno.osRelease()}`
3030

3131
return `neo4j-javascript/${version} (${OS_NAME_VERSION}; ${HOST_ARCH}) ${DENO_VERSION} (v8 ${NODE_V8_VERSION})`
3232
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
/* eslint-disable */
20+
//@ts-ignore
21+
import { fromVersion } from '../../../../../src/internal/bolt-agent/deno/bolt-agent.ts'
22+
//@ts-ignore
23+
import { assertMatch, assertEquals } from "https://deno.land/std@0.182.0/testing/asserts.ts";
24+
25+
//@ts-ignore
26+
Deno.test('Test Contains deno and javascript', () => {
27+
const boltAgent = fromVersion("5.3")
28+
assertMatch(boltAgent, new RegExp("^neo4j-javascript/5.3"))
29+
assertMatch(boltAgent, new RegExp("Deno/"))
30+
});
31+
32+
//@ts-ignore
33+
Deno.test('Test full bolt agent', () => {
34+
//@ts-ignore
35+
const HOST_ARCH = Deno.build.arch
36+
//@ts-ignore
37+
const DENO_VERSION = `Deno/${Deno.version.deno}`
38+
//@ts-ignore
39+
const NODE_V8_VERSION = Deno.version.v8
40+
//@ts-ignore
41+
const OS_NAME_VERSION = `${Deno.build.os} ${Deno.osRelease()}`
42+
43+
const boltAgentExpected = `neo4j-javascript/5.3 (${OS_NAME_VERSION}; ${HOST_ARCH}) ${DENO_VERSION} (v8 ${NODE_V8_VERSION})`
44+
45+
assertEquals(fromVersion("5.3"), boltAgentExpected)
46+
});
47+
/* eslint-enable */

packages/neo4j-driver-deno/lib/core/internal/bolt-agent/browser/bolt-agent.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
export function fromVersion (version: string): string {
20-
window.navagator
19+
/* eslint-disable */
20+
// @ts-ignore: browser code so must be skipped by ts
21+
export function fromVersion (version: string, windowProvider = () => window): string {
22+
// @ts-ignore: browser code so must be skipped by ts
23+
const APP_VERSION = windowProvider().navigator.appVersion
2124

22-
return `neo4j-javascript/${version} (browser)}`
25+
//APP_VERSION looks like 5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
26+
const OS = APP_VERSION.split("(")[1].split(")")[0];
27+
28+
return `neo4j-javascript/${version} (${OS})`
2329
}
30+
/* eslint-enable */

packages/neo4j-driver-deno/lib/core/internal/bolt-agent/deno/bolt-agent.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
* limitations under the License.
1818
*/
1919

20+
/* eslint-disable */
2021
export function fromVersion (version: string): string {
22+
//@ts-ignore
2123
const HOST_ARCH = Deno.build.arch
22-
const DENO_VERSION = 'Deno/' + Deno.version.deno
24+
//@ts-ignore
25+
const DENO_VERSION = `Deno/${Deno.version.deno}`
26+
//@ts-ignore
2327
const NODE_V8_VERSION = Deno.version.v8
24-
const OS_NAME_VERSION = `${Deno.build.os} ${Deno.osRelease}`
28+
//@ts-ignore
29+
const OS_NAME_VERSION = `${Deno.build.os} ${Deno.osRelease()}`
2530

2631
return `neo4j-javascript/${version} (${OS_NAME_VERSION}; ${HOST_ARCH}) ${DENO_VERSION} (v8 ${NODE_V8_VERSION})`
2732
}
33+
/* eslint-enable */

packages/neo4j-driver-deno/lib/core/internal/bolt-agent/node/bolt-agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ export function fromVersion (version: string): string {
2525
const OS_NAME_VERSION = `${os.platform()} ${os.release()}`
2626

2727
return `neo4j-javascript/${version} (${OS_NAME_VERSION}; ${HOST_ARCH}) ${NODE_VERSION} (v8 ${NODE_V8_VERSION})`
28-
}
28+
}

0 commit comments

Comments
 (0)