-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v3.1.0 release * update pipeline
- Loading branch information
Showing
51 changed files
with
1,301 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* global describe, it, expect */ | ||
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const planId = 12345 | ||
const status = 'ONGOING' | ||
|
||
describe('#changePlanStatus', () => { | ||
it.each([ | ||
[null, null], | ||
[null, status], | ||
[planId, null] | ||
])('should throw MissingParameterError given missing params', (planId, status) => { | ||
expect(() => { | ||
SpotClient.changePlanStatus(planId, status) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
|
||
it('should change plan status', () => { | ||
const parameters = { | ||
recvWindow | ||
} | ||
nockPostMock(`/sapi/v1/lending/auto-invest/plan/edit-status?${buildQueryString({ planId, status, ...parameters })}`)(mockResponse) | ||
return SpotClient.changePlanStatus(planId, status, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const planType = 'SINGLE' | ||
|
||
describe('#getListOfPlans', () => { | ||
it('throw MissingParameterError when missing planType', () => { | ||
expect(() => { | ||
SpotClient.getListOfPlans(null) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
it('should get list of plans', () => { | ||
const parameters = { | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/plan/list?${buildQueryString({ planType, ...parameters })}`)(mockResponse) | ||
return SpotClient.getListOfPlans(planType, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const size = 100 | ||
const current = 1 | ||
|
||
describe('#getTargetAssetList', () => { | ||
it('should get target asset list without parameter attached', () => { | ||
nockMock('/sapi/v1/lending/auto-invest/target-asset/list')(mockResponse) | ||
return SpotClient.getTargetAssetList().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should get target asset list', () => { | ||
const parameters = { | ||
size, | ||
current, | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/target-asset/list?${buildQueryString({ ...parameters })}`)(mockResponse) | ||
return SpotClient.getTargetAssetList(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const targetAsset = 'BTC' | ||
const hisRoiType = 'FIVE_YEAR' | ||
|
||
describe('#getTargetAssetRoiData', () => { | ||
it.each([ | ||
[null, null], | ||
[null, hisRoiType], | ||
[targetAsset, null] | ||
])('should throw MissingParameterError given missing params', (targetAsset, hisRoiType) => { | ||
expect(() => { | ||
SpotClient.getTargetAssetRoiData(targetAsset, hisRoiType) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
|
||
it('should get target asset roi data', () => { | ||
const parameters = { | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/target-asset/roi/list?${buildQueryString({ targetAsset, hisRoiType, ...parameters })}`)(mockResponse) | ||
return SpotClient.getTargetAssetRoiData(targetAsset, hisRoiType, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
33 changes: 33 additions & 0 deletions
33
__tests__/spot/auto-invest/indexLinkedPlanRebalanceDetails.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const current = 1 | ||
const size = 100 | ||
|
||
describe('#indexLinkedPlanRebalanceDetails', () => { | ||
it('should index linked plan rebalance details without parameter attached', () => { | ||
nockMock('/sapi/v1/lending/auto-invest/rebalance/history')(mockResponse) | ||
return SpotClient.indexLinkedPlanRebalanceDetails().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should index linked plan rebalance details', () => { | ||
const parameters = { | ||
current, | ||
size, | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/rebalance/history?${buildQueryString({ ...parameters })}`)(mockResponse) | ||
return SpotClient.indexLinkedPlanRebalanceDetails(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
__tests__/spot/auto-invest/indexLinkedPlanRedemption.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* global describe, it, expect */ | ||
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const requestId = 12345 | ||
const indexId = 1 | ||
const redemptionPercentage = 10 | ||
|
||
describe('#indexLinkedPlanRedemption', () => { | ||
it('throw MissingParameterError when missing requestId', () => { | ||
expect(() => { | ||
SpotClient.indexLinkedPlanRedemption(null) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
it('should index linked plan redemption', () => { | ||
const parameters = { | ||
requestId, | ||
recvWindow | ||
} | ||
nockPostMock(`/sapi/v1/lending/auto-invest/redeem?${buildQueryString({ indexId, redemptionPercentage, ...parameters })}`)(mockResponse) | ||
return SpotClient.indexLinkedPlanRedemption(indexId, redemptionPercentage, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
34 changes: 34 additions & 0 deletions
34
__tests__/spot/auto-invest/indexLinkedPlanRedemptionHistory.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
asset, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const requestId = 12345 | ||
const current = 1 | ||
const size = 100 | ||
|
||
describe('#indexLinkedPlanRedemptionHistory', () => { | ||
it('throw MissingParameterError when missing requestId', () => { | ||
expect(() => { | ||
SpotClient.indexLinkedPlanRedemptionHistory(null) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
it('should index linked plan redemption history', () => { | ||
const parameters = { | ||
current, | ||
asset, | ||
size, | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/redeem/history?${buildQueryString({ requestId, ...parameters })}`)(mockResponse) | ||
return SpotClient.indexLinkedPlanRedemptionHistory(requestId, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
28 changes: 28 additions & 0 deletions
28
__tests__/spot/auto-invest/queryAllSourceAssetAndTargetAsset.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
describe('#queryAllSourceAssetAndTargetAsset', () => { | ||
it('should query all source asset and target asset without parameter attached', () => { | ||
nockMock('/sapi/v1/lending/auto-invest/all/asset')(mockResponse) | ||
return SpotClient.queryAllSourceAssetAndTargetAsset().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should query all source asset and target asset', () => { | ||
const parameters = { | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/all/asset?${buildQueryString({ ...parameters })}`)(mockResponse) | ||
return SpotClient.queryAllSourceAssetAndTargetAsset(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const indexId = 1 | ||
|
||
describe('#queryIndexDetails', () => { | ||
it('throw MissingParameterError when missing indexId', () => { | ||
expect(() => { | ||
SpotClient.queryIndexDetails(null) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
it('should query index details', () => { | ||
const parameters = { | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/index/info?${buildQueryString({ indexId, ...parameters })}`)(mockResponse) | ||
return SpotClient.queryIndexDetails(indexId, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
28 changes: 28 additions & 0 deletions
28
__tests__/spot/auto-invest/queryIndexLinkedPlanPositionDetails.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const { | ||
mockResponse, | ||
recvWindow | ||
} = require('../../testUtils/mockData') | ||
|
||
const indexId = 1 | ||
|
||
describe('#queryIndexLinkedPlanPositionDetails', () => { | ||
it('throw MissingParameterError when missing indexId', () => { | ||
expect(() => { | ||
SpotClient.queryIndexLinkedPlanPositionDetails(null) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
it('should query index linked plan position details', () => { | ||
const parameters = { | ||
recvWindow | ||
} | ||
nockMock(`/sapi/v1/lending/auto-invest/index/user-summary?${buildQueryString({ indexId, ...parameters })}`)(mockResponse) | ||
return SpotClient.queryIndexLinkedPlanPositionDetails(indexId, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.