-
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.
Merge pull request #153 from Danswar/Simple-Earn-endpoints
Simple Earn module
- Loading branch information
Showing
25 changed files
with
1,245 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* global describe, it, expect */ | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
const productId = '1' | ||
|
||
describe('#getCollateralRecord', () => { | ||
describe('throw MissingParameterError', () => { | ||
it('missing productId', () => { | ||
expect(() => { | ||
SpotClient.getCollateralRecord('') | ||
}).toThrow(MissingParameterError) | ||
}) | ||
}) | ||
it('should suscribe locked product', () => { | ||
const parameters = { | ||
productId | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/history/collateralRecord?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getCollateralRecord(productId).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
28 changes: 28 additions & 0 deletions
28
__tests__/spot/simpleEarn/getFlexiblePersonalLeftQuota.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 MissingParameterError = require('../../../src/error/missingParameterError') | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
const productId = '1' | ||
|
||
describe('#getFlexiblePersonalLeftQuota', () => { | ||
describe('throw MissingParameterError', () => { | ||
it('missing productId', () => { | ||
expect(() => { | ||
SpotClient.getFlexiblePersonalLeftQuota('') | ||
}).toThrow(MissingParameterError) | ||
}) | ||
}) | ||
it('should redeem flexible product', () => { | ||
const parameters = { | ||
productId | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/personalLeftQuota?${buildQueryString({ ...parameters })}`)(mockResponse) | ||
|
||
return SpotClient.getFlexiblePersonalLeftQuota(productId).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, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getFlexibleProductList', () => { | ||
it('should return flexible product list', () => { | ||
nockMock('/sapi/v1/simple-earn/flexible/list')(mockResponse) | ||
|
||
return SpotClient.getFlexibleProductList().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return flexible product list with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/list?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getFlexibleProductList(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
29 changes: 29 additions & 0 deletions
29
__tests__/spot/simpleEarn/getFlexibleProductPosition.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,29 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getFlexibleProductPosition', () => { | ||
it('should return flexible product position', () => { | ||
nockMock('/sapi/v1/simple-earn/flexible/position')(mockResponse) | ||
|
||
return SpotClient.getFlexibleProductPosition().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return flexible product position with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
productId: '1', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/position?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getFlexibleProductPosition(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
29 changes: 29 additions & 0 deletions
29
__tests__/spot/simpleEarn/getFlexibleRedemptionRecord.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,29 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getFlexibleRedemptionRecord', () => { | ||
it('should return flexible redemption records', () => { | ||
nockMock('/sapi/v1/simple-earn/flexible/history/redemptionRecord')(mockResponse) | ||
|
||
return SpotClient.getFlexibleRedemptionRecord().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return flexible redemption records with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
productId: '1', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/history/redemptionRecord?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getFlexibleRedemptionRecord(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
30 changes: 30 additions & 0 deletions
30
__tests__/spot/simpleEarn/getFlexibleRewardsRecord.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,30 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
|
||
const type = 'FLEXIBLE' | ||
|
||
describe('#getFlexibleRewardsRecord', () => { | ||
describe('throw MissingParameterError', () => { | ||
it('missing productId', () => { | ||
expect(() => { | ||
SpotClient.getFlexibleRewardsRecord('') | ||
}).toThrow(MissingParameterError) | ||
}) | ||
}) | ||
|
||
it('should return locked records history with params', () => { | ||
const parameters = { | ||
type, | ||
productId: '1', | ||
asset: 'USDT' | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/history/rewardsRecord?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getFlexibleRewardsRecord(type, parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
36 changes: 36 additions & 0 deletions
36
__tests__/spot/simpleEarn/getFlexibleSubscriptionPreview.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,36 @@ | ||
/* global describe, it, expect */ | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
const productId = '1' | ||
const amount = 10 | ||
|
||
describe('#getFlexibleSubscriptionPreview', () => { | ||
describe('throw MissingParameterError', () => { | ||
it('missing productId', () => { | ||
expect(() => { | ||
SpotClient.getFlexibleSubscriptionPreview('', amount) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
|
||
it('missing amount', () => { | ||
expect(() => { | ||
SpotClient.getFlexibleSubscriptionPreview(productId, '') | ||
}).toThrow(MissingParameterError) | ||
}) | ||
}) | ||
it('should suscribe locked product', () => { | ||
const parameters = { | ||
productId, | ||
amount | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/subscriptionPreview?${buildQueryString({ ...parameters })}`)(mockResponse) | ||
|
||
return SpotClient.getFlexibleSubscriptionPreview(productId, amount).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
29 changes: 29 additions & 0 deletions
29
__tests__/spot/simpleEarn/getFlexibleSubscriptionRecord.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,29 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getFlexibleSubscriptionRecord', () => { | ||
it('should return flexible subscription records', () => { | ||
nockMock('/sapi/v1/simple-earn/flexible/history/subscriptionRecord')(mockResponse) | ||
|
||
return SpotClient.getFlexibleSubscriptionRecord().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return flexible subscription records with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
purchaseId: '1', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/flexible/history/subscriptionRecord?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getFlexibleSubscriptionRecord(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
28 changes: 28 additions & 0 deletions
28
__tests__/spot/simpleEarn/getLockedPersonalLeftQuota.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 MissingParameterError = require('../../../src/error/missingParameterError') | ||
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
const productId = '1' | ||
|
||
describe('#getLockedPersonalLeftQuota', () => { | ||
describe('throw MissingParameterError', () => { | ||
it('missing productId', () => { | ||
expect(() => { | ||
SpotClient.getLockedPersonalLeftQuota('') | ||
}).toThrow(MissingParameterError) | ||
}) | ||
}) | ||
it('should redeem flexible product', () => { | ||
const parameters = { | ||
productId | ||
} | ||
nockMock(`/sapi/v1/simple-earn/locked/personalLeftQuota?${buildQueryString({ ...parameters })}`)(mockResponse) | ||
|
||
return SpotClient.getLockedPersonalLeftQuota(productId).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, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getLockedProductList', () => { | ||
it('should return locked product list', () => { | ||
nockMock('/sapi/v1/simple-earn/locked/list')(mockResponse) | ||
|
||
return SpotClient.getLockedProductList().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return locked product list with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/locked/list?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getLockedProductList(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
29 changes: 29 additions & 0 deletions
29
__tests__/spot/simpleEarn/getLockedProductPosition.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,29 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getLockedProductPosition', () => { | ||
it('should return locked product position', () => { | ||
nockMock('/sapi/v1/simple-earn/locked/position')(mockResponse) | ||
|
||
return SpotClient.getLockedProductPosition().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return locked product position with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
productId: '1', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/locked/position?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getLockedProductPosition(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
29 changes: 29 additions & 0 deletions
29
__tests__/spot/simpleEarn/getLockedRedemptionRecord.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,29 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getLockedRedemptionRecord', () => { | ||
it('should return locked redemption records', () => { | ||
nockMock('/sapi/v1/simple-earn/locked/history/redemptionRecord')(mockResponse) | ||
|
||
return SpotClient.getLockedRedemptionRecord().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return locked redemption records with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
productId: '1', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/locked/history/redemptionRecord?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getLockedRedemptionRecord(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,29 @@ | ||
/* global describe, it, expect */ | ||
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') | ||
const { mockResponse } = require('../../testUtils/mockData') | ||
|
||
describe('#getLockedRewardsRecord', () => { | ||
it('should return locked records history', () => { | ||
nockMock('/sapi/v1/simple-earn/locked/history/rewardsRecord')(mockResponse) | ||
|
||
return SpotClient.getLockedRewardsRecord().then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
|
||
it('should return locked records history with params', () => { | ||
const parameters = { | ||
asset: 'USDT', | ||
positionId: '1', | ||
current: 5, | ||
size: 10 | ||
} | ||
nockMock(`/sapi/v1/simple-earn/locked/history/rewardsRecord?${buildQueryString(parameters)}`)(mockResponse) | ||
|
||
return SpotClient.getLockedRewardsRecord(parameters).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.