1
1
/* eslint-env browser, node, mocha */
2
2
3
3
import { expect } from 'aegir/utils/chai'
4
- import { Configuration , PinsApi , Status } from '../src'
4
+ import { Configuration , RemotePinningServiceClient , Status } from '../src'
5
5
import type { Pin } from '../src'
6
6
import fetchPonyfill from 'fetch-ponyfill'
7
7
8
8
const { fetch } = fetchPonyfill ( )
9
9
10
10
let Config = new Configuration ( {
11
- basePath : 'http://127.0.0.1:3000' ,
11
+ endpointUrl : 'http://127.0.0.1:3000' ,
12
12
// fetchApi: fetch,
13
13
accessToken : process . env . MOCK_PINNING_SERVER_SECRET
14
14
} )
15
15
describe ( 'Client' , ( ) => {
16
16
it ( 'Can be instantiated' , ( ) => {
17
- expect ( ( ) => new PinsApi ( Config ) ) . not . to . throw ( )
17
+ expect ( ( ) => new RemotePinningServiceClient ( Config ) ) . not . to . throw ( )
18
18
} )
19
19
20
20
describe ( 'Operations' , ( ) => {
21
21
// let mockServer: MockServer
22
22
// let Config: Configuration
23
23
beforeEach ( async ( ) => {
24
24
const response = await fetch ( 'http://localhost:3000/start' )
25
- const { basePath , accessToken } = await response . json ( )
25
+ const { endpointUrl , accessToken } = await response . json ( )
26
26
Config = new Configuration ( {
27
- basePath ,
27
+ endpointUrl ,
28
28
accessToken
29
29
// fetchApi: fetch
30
30
} )
@@ -42,13 +42,13 @@ describe('Client', () => {
42
42
} )
43
43
44
44
it ( 'GET: Can get failed Pins' , async ( ) => {
45
- const Client = new PinsApi ( Config )
45
+ const Client = new RemotePinningServiceClient ( Config )
46
46
const response = await Client . pinsGet ( { limit : 1 , status : new Set ( [ Status . Failed ] ) } )
47
47
expect ( response ) . to . deep . eq ( { count : 0 , results : new Set ( ) } )
48
48
} )
49
49
50
50
it ( 'GET: Can add a Pin successfully' , async ( ) => {
51
- const Client = new PinsApi ( Config )
51
+ const Client = new RemotePinningServiceClient ( Config )
52
52
const pin : Pin = {
53
53
cid : 'abc123' ,
54
54
name : 'pinned-test1'
@@ -59,7 +59,7 @@ describe('Client', () => {
59
59
} )
60
60
61
61
it ( 'POST: Can handle a failed pinning' , async ( ) => {
62
- const Client = new PinsApi ( Config )
62
+ const Client = new RemotePinningServiceClient ( Config )
63
63
const pin : Pin = {
64
64
cid : 'abc123' ,
65
65
name : 'failed-test2'
0 commit comments