File tree Expand file tree Collapse file tree 5 files changed +108
-74
lines changed Expand file tree Collapse file tree 5 files changed +108
-74
lines changed Original file line number Diff line number Diff line change 19
19
linting :
20
20
name : " Linting"
21
21
uses : SocketDev/workflows/.github/workflows/reusable-base.yml@master
22
- secrets : inherit
23
22
with :
24
23
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'
Original file line number Diff line number Diff line change 39
39
"eslint-plugin-promise" : " ^6.0.1" ,
40
40
"eslint-plugin-react" : " ^7.31.9" ,
41
41
"eslint-plugin-react-hooks" : " ^4.6.0" ,
42
+ "nock" : " ^13.2.9" ,
42
43
"npm-run-all2" : " ^6.0.2" ,
43
44
"tap" : " ^16.3.0" ,
44
45
"typescript" : " ^4.8.4"
48
49
"build:1-typescript" : " tsc -p tsconfig.json" ,
49
50
"build:2-minify-json" : " node build/minify-dist-json.js" ,
50
51
"build" : " run-s build:*" ,
51
- "lint" : " eslint ." ,
52
+ "ci-test-old" : " run-s build test-old:*" ,
53
+ "ci-test" : " run-s build test:*" ,
52
54
"clean" : " rm -rf dist" ,
53
55
"generate-sdk:0-prettify" : " node build/prettify-base-json.js" ,
54
56
"generate-sdk:1-generate" : " node build/generate-sdk.js" ,
55
57
"generate-sdk" : " run-s generate-sdk:*" ,
58
+ "lint" : " eslint ." ,
56
59
"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:*"
58
63
}
59
64
}
Original file line number Diff line number Diff line change
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
+ } )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments