File tree 7 files changed +3769
-157
lines changed
7 files changed +3769
-157
lines changed Original file line number Diff line number Diff line change
1
+ name : " Check PR"
2
+ on :
3
+ pull_request :
4
+
5
+ jobs :
6
+ build :
7
+ name : Build
8
+ runs-on : ubuntu-latest
9
+
10
+ steps :
11
+ - name : Checkout code
12
+ uses : actions/checkout@v4
13
+
14
+ - name : Cache node modules
15
+ id : cache
16
+ uses : actions/cache@v3
17
+ with :
18
+ path : |
19
+ ~/.cache
20
+ **/node_modules
21
+ key : cache-node-modules-${{ hashFiles('yarn.lock') }}
22
+ restore-keys : |
23
+ cache-node-modules-
24
+
25
+ - name : Set up Node
26
+ uses : actions/setup-node@v4
27
+ with :
28
+ node-version : 20
29
+
30
+ - name : yarn install
31
+ if : steps.cache.outputs.cache-hit != 'true'
32
+ shell : bash
33
+ run : yarn install --immutable
34
+
35
+ - name : Build
36
+ shell : bash
37
+ run : yarn build
38
+
39
+ test :
40
+ name : Test (${{ matrix.node }})
41
+ needs : [build]
42
+ strategy :
43
+ matrix :
44
+ os :
45
+ - " ubuntu-latest"
46
+ node :
47
+ - " 20"
48
+ - " 18"
49
+ runs-on : ${{ matrix.os }}
50
+ steps :
51
+ - uses : actions/checkout@v2
52
+
53
+ - name : Setup node
54
+ uses : actions/setup-node@v2
55
+ with :
56
+ node-version : ${{ matrix.node }}
57
+
58
+ - name : Print Node.js version
59
+ run : node -v
60
+
61
+ - name : Cache node modules
62
+ id : cache
63
+ uses : actions/cache@v3
64
+ with :
65
+ path : |
66
+ ~/.cache
67
+ **/node_modules
68
+ key : cache-node-modules-${{ hashFiles('yarn.lock') }}
69
+ restore-keys : |
70
+ cache-node-modules-
71
+
72
+ - name : Test
73
+ run : yarn test
Original file line number Diff line number Diff line change
1
+ /** @type {import('ts-jest').JestConfigWithTsJest } */
2
+ module . exports = {
3
+ preset : 'ts-jest' ,
4
+ testEnvironment : 'node'
5
+ }
Original file line number Diff line number Diff line change 29
29
"module" : " ./dist/esm/index.js" ,
30
30
"scripts" : {
31
31
"build" : " tsc && tsc -p tsconfig.esm.json" ,
32
- "generate:sdk" : " node ./generate-models.js && yarn build"
32
+ "generate:sdk" : " node ./generate-models.js && yarn build" ,
33
+ "test" : " jest"
33
34
},
34
35
"dependencies" : {
35
36
"axios" : " ^1.6.2"
36
37
},
37
38
"devDependencies" : {
39
+ "@jest/globals" : " ^29.7.0" ,
40
+ "@types/jest" : " ^29.5.11" ,
38
41
"@types/node" : " ^20.10.4" ,
42
+ "jest" : " ^29.7.0" ,
39
43
"openapi-typescript-codegen" : " ^0.25.0" ,
44
+ "ts-jest" : " ^29.1.1" ,
40
45
"typescript" : " ^5.3"
41
46
},
42
47
"packageManager" :
" [email protected] "
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ export default class Doczilla {
18
18
public readonly webhook : WebhookService
19
19
20
20
constructor ( token : string , options : DoczillaOptions = { } ) {
21
+ if ( ! token ) {
22
+ throw new Error ( 'No token provided!' )
23
+ }
24
+
21
25
this . client = axios . create ( {
22
26
baseURL : options . baseURL || 'https://api.doczilla.app' ,
23
27
headers : {
Original file line number Diff line number Diff line change
1
+ import { describe , expect , test } from '@jest/globals'
2
+
3
+ import Doczilla from '../Doczilla'
4
+
5
+ describe ( 'Doczilla' , ( ) => {
6
+
7
+ test ( 'it should throw an error if no api key is provided' , ( ) => {
8
+ let error : Error
9
+ try {
10
+ // @ts -expect-error
11
+ new Doczilla ( )
12
+ } catch ( err ) {
13
+ error = err
14
+ }
15
+
16
+ expect ( error . message ) . toEqual ( 'No token provided!' )
17
+ } )
18
+
19
+ } )
Original file line number Diff line number Diff line change 11
11
"resolveJsonModule" : true ,
12
12
"typeRoots" : [
13
13
" node_modules/@types"
14
+ ],
15
+ "types" : [
16
+ " node" ,
17
+ " jest"
14
18
]
15
19
},
16
20
"exclude" : [
You can’t perform that action at this time.
0 commit comments