Skip to content

Commit 727e853

Browse files
committed
Run tests on CI
1 parent a8af063 commit 727e853

File tree

5 files changed

+108
-74
lines changed

5 files changed

+108
-74
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ jobs:
1919
linting:
2020
name: "Linting"
2121
uses: SocketDev/workflows/.github/workflows/reusable-base.yml@master
22-
secrets: inherit
2322
with:
2423
npm-test-script: 'lint'
24+
test-old:
25+
name: "Tests"
26+
uses: SocketDev/workflows/.github/workflows/reusable-base.yml@master
27+
with:
28+
npm-test-script: 'ci-test-old'
29+
node-versions: '14,16'
30+
test:
31+
name: "Tests"
32+
uses: SocketDev/workflows/.github/workflows/reusable-base.yml@master
33+
with:
34+
npm-test-script: 'ci-test'
35+
node-versions: '18,19'

package-lock.json

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

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"eslint-plugin-promise": "^6.0.1",
4040
"eslint-plugin-react": "^7.31.9",
4141
"eslint-plugin-react-hooks": "^4.6.0",
42+
"nock": "^13.2.9",
4243
"npm-run-all2": "^6.0.2",
4344
"tap": "^16.3.0",
4445
"typescript": "^4.8.4"
@@ -48,12 +49,16 @@
4849
"build:1-typescript": "tsc -p tsconfig.json",
4950
"build:2-minify-json": "node build/minify-dist-json.js",
5051
"build": "run-s build:*",
51-
"lint": "eslint .",
52+
"ci-test-old": "run-s build test-old:*",
53+
"ci-test": "run-s build test:*",
5254
"clean": "rm -rf dist",
5355
"generate-sdk:0-prettify": "node build/prettify-base-json.js",
5456
"generate-sdk:1-generate": "node build/generate-sdk.js",
5557
"generate-sdk": "run-s generate-sdk:*",
58+
"lint": "eslint .",
5659
"prepublishOnly": "run-s build",
57-
"test": "run-s lint"
60+
"test-old:tap": "tap --no-check-coverage",
61+
"test:tap": "tap --no-check-coverage --node-arg=--no-experimental-fetch",
62+
"test": "run-s lint build test:*"
5863
}
5964
}

tests/basic.test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const nock = require('nock')
2+
const t = require('tap')
3+
4+
const { default: api } = require('../dist')
5+
6+
const client = api.auth('yetAnotherApiKey')
7+
8+
t.test('Endpoints', async t => {
9+
t.beforeEach(() => {
10+
console.log('hi')
11+
nock.cleanAll()
12+
nock.disableNetConnect()
13+
})
14+
15+
t.afterEach(() => {
16+
console.log('hi2')
17+
if (!nock.isDone()) {
18+
throw new Error('pending nock mocks: ' + nock.pendingMocks())
19+
}
20+
})
21+
22+
t.test('getQuota', async t => {
23+
nock('https://api.socket.dev')
24+
.get('/v0/quota')
25+
.reply(200, { quota: 1e9 })
26+
const res = await client.getQuota()
27+
t.same(res, { quota: 1e9 })
28+
})
29+
t.test('getIssuesByNPMPackage', async t => {
30+
t.test('must return empty issue list', async t => {
31+
nock('https://api.socket.dev')
32+
.get('/v0/npm/speed-limiter/1.0.0/issues')
33+
.reply(200, [])
34+
const res = await client.getIssuesByNPMPackage({
35+
package: 'speed-limiter',
36+
version: '1.0.0'
37+
})
38+
t.same(res, [])
39+
})
40+
})
41+
})

tests/basic.test.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)