Skip to content

Commit 01eb3ac

Browse files
committed
test: Add a simple typescript integration test
1 parent 46e4e56 commit 01eb3ac

File tree

7 files changed

+153
-0
lines changed

7 files changed

+153
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.htm text diff=html eol=lf
77
*.html text diff=html eol=lf
88
*.js text eol=lf
9+
*.ts text eol=lf
910
*.mjs text eol=lf
1011
*.cjs text eol=lf
1112
*.json text eol=lf

itest/es6-ts/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# typescript generated
3+
*.js
4+
*.js.map
5+

itest/es6-ts/main.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
import JsonURL from "@jsonurl/jsonurl";
3+
import { readFileSync } from "fs";
4+
const pkg = JSON.parse(String(readFileSync("package.json")));
5+
const expected = "(hello:world)";
6+
7+
function assert(actual) {
8+
if (actual !== expected) {
9+
console.log(
10+
pkg.description,
11+
": expected '" + expected + "' but received '" + actual + "'"
12+
);
13+
14+
process.exit(1);
15+
}
16+
}
17+
18+
assert(JsonURL.stringify(JsonURL.parse(expected)));
19+

itest/es6-ts/package-lock.json

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

itest/es6-ts/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@jsonurl/itest-es6-ts",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "JSON->URL node ES6+Typescript integration test",
6+
"main": "main.js",
7+
"type": "module",
8+
"scripts": {
9+
"build": "npx tsc",
10+
"test": "node ./"
11+
},
12+
"author": "David MacCormack",
13+
"license": "MIT",
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/jsonurl/jsonurl-js.git"
17+
},
18+
"bugs": {
19+
"url": "https://github.com/jsonurl/jsonurl-js/issues"
20+
},
21+
"homepage": "https://www.jsonurl.org/",
22+
"dependencies": {
23+
"@jsonurl/jsonurl": "file:../..",
24+
"typescript": "^4.8.4"
25+
}
26+
}

itest/es6-ts/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"moduleResolution": "node",
5+
"sourceMap": true
6+
}
7+
}

itest/itest.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ itest es6-babel || test_es6babel_status=1
6868
test_jsdom_status=0
6969
itest jsdom || test_jsdom_status=1
7070

71+
test_es6ts_status=0
72+
itest es6-ts || test_es6ts_status=1
73+
7174
#
7275
# This test depends on the version of node.
7376
# node < 11 : no support for native ES6 modules
@@ -93,11 +96,13 @@ itest_status cjs $test_cjs_status
9396
itest_status es6-babel $test_es6babel_status
9497
itest_status es6-native $test_es6native_status
9598
itest_status jsdom $test_jsdom_status
99+
itest_status es6-ts $test_es6ts_status
96100

97101
itest_exit cjs $test_cjs_exit
98102
itest_exit es6-babel $test_es6babel_exit
99103
itest_exit es6-native $test_es6native_exit
100104
itest_exit jsdom $test_jsdom_exit
105+
itest_exit es6-ts $test_es6ts_exit
101106

102107
exit 0
103108

0 commit comments

Comments
 (0)