File tree 3 files changed +45
-1
lines changed
packages/@ackee/antonio-core/src/modules/core/models/__tests__
3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 62
62
"typedoc" : " ^0.21.0" ,
63
63
"typedoc-github-wiki-theme" : " ^0.4.1" ,
64
64
"typedoc-plugin-markdown" : " ^3.10.0" ,
65
- "typescript" : " 4.x"
65
+ "typescript" : " 4.x" ,
66
+ "whatwg-fetch" : " ^3.6.2"
66
67
},
67
68
"husky" : {
68
69
"hooks" : {
Original file line number Diff line number Diff line change
1
+ import 'whatwg-fetch' ;
2
+ import { generatorToPromise as toPromise } from '../../makeRequest' ;
3
+ import { Antonio } from '../Antonio' ;
4
+
5
+ describe ( 'Antonio class' , ( ) => {
6
+ let api : Antonio ;
7
+
8
+ beforeEach ( ( ) => {
9
+ api = new Antonio ( {
10
+ baseURL : 'https://jsonplaceholder.typicode.com/' ,
11
+ } ) ;
12
+ } ) ;
13
+
14
+ afterEach ( ( ) => {
15
+ api . destroy ( ) ;
16
+ } ) ;
17
+
18
+ it ( 'fetch users' , async ( ) => {
19
+ const { data, response, request } = await toPromise ( api . get ( '/users' ) ) ;
20
+
21
+ expect ( data ) . toBeInstanceOf ( Array ) ;
22
+ expect ( response ) . toBeInstanceOf ( Response ) ;
23
+ expect ( request ) . toBeInstanceOf ( Request ) ;
24
+ } ) ;
25
+
26
+ // TODO:
27
+ it . skip ( 'create a user' , async ( ) => {
28
+ interface User {
29
+ name : string ;
30
+ }
31
+ const user : User = {
32
+ name : 'Alois' ,
33
+ } ;
34
+ const { data } = await toPromise ( api . post ( '/users' , user ) ) ;
35
+
36
+ expect ( data ) . toContain ( user ) ;
37
+ } ) ;
38
+ } ) ;
Original file line number Diff line number Diff line change @@ -11040,6 +11040,11 @@ whatwg-encoding@^1.0.5:
11040
11040
dependencies :
11041
11041
iconv-lite "0.4.24"
11042
11042
11043
+ whatwg-fetch@^3.6.2 :
11044
+ version "3.6.2"
11045
+ resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
11046
+ integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==
11047
+
11043
11048
whatwg-mimetype@^2.3.0 :
11044
11049
version "2.3.0"
11045
11050
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
You can’t perform that action at this time.
0 commit comments