Skip to content

Commit 71b1958

Browse files
committed
chore: Add integration test suite
1 parent e4c83f8 commit 71b1958

20 files changed

+45598
-4
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
- run: npm run lint
4242
- run: npm run build
4343
- run: npm test
44+
- name: Integration Test
45+
run: cd itest && ./itest.sh
4446
- name: Package artifacts
4547
uses: actions/upload-artifact@v2
4648
if: success()
@@ -50,7 +52,7 @@ jobs:
5052

5153
matrix-build:
5254
needs: artifact
53-
if: needs.artifact.result == 'success'
55+
if: ${{ needs.artifact.result == 'success' }}
5456
runs-on: ${{ matrix.os }}
5557
strategy:
5658
matrix:
@@ -75,12 +77,14 @@ jobs:
7577
- run: npm run lint
7678
- run: npm run build
7779
- run: npm test
80+
- name: Integration Test
81+
run: cd itest && ./itest.sh
7882

7983
sonarcloud:
8084
needs: artifact
8185
if: |
82-
needs.artifact.result == 'success'
83-
&& github.repository_owner == 'jsonurl'
86+
${{ needs.artifact.result == 'success'
87+
&& github.repository_owner == 'jsonurl' }}
8488
runs-on: ubuntu-latest
8589
steps:
8690
- uses: actions/checkout@v2

itest/cjs/.eslintrc.cjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2020 David MacCormack
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
"use strict";
26+
27+
module.exports = {
28+
extends: ["../../.eslintrc.js"],
29+
overrides: [
30+
{
31+
files: ["main.js"],
32+
env: {
33+
node: true,
34+
},
35+
},
36+
],
37+
};

itest/cjs/main.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2020 David MacCormack
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
const JsonURL = require("@jsonurl/jsonurl");
26+
const pkg = require("./package.json");
27+
const expected = "(hello:world)";
28+
29+
function assert(actual) {
30+
if (actual !== expected) {
31+
console.log(
32+
pkg.description,
33+
": expected '" + expected + "' but received '" + actual + "'"
34+
);
35+
36+
process.exit(1);
37+
}
38+
}
39+
40+
const u = new JsonURL();
41+
assert(JsonURL.stringify(u.parse(expected)));
42+
assert(JsonURL.stringify(JsonURL.parse(expected)));

0 commit comments

Comments
 (0)