Skip to content

Commit 2f5efd2

Browse files
committed
Fix PR comments
1 parent 02cd532 commit 2f5efd2

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

packages/plugin-xtreamly/__tests__/actions/retrieveVolatilityState.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('retrieveVolatilityPrediction', () => {
6363
describe('validation', () => {
6464
it('should validate successfully when API is up and running', async () => {
6565
mockFetch.mockResolvedValueOnce({
66+
ok: true,
6667
json: () => Promise.resolve({ status: 'ok' }),
6768
});
6869
const result = await retrieveVolatilityState.validate(mockRuntime, mockMessage);
@@ -71,6 +72,7 @@ describe('retrieveVolatilityPrediction', () => {
7172

7273
it('should fail validation when API is down', async () => {
7374
mockFetch.mockResolvedValueOnce({
75+
ok: true,
7476
json: () => Promise.resolve({ status: 'down' }),
7577
});
7678
const result = await retrieveVolatilityState.validate(mockRuntime, mockMessage);
@@ -97,6 +99,7 @@ describe('retrieveVolatilityPrediction', () => {
9799
const mockFormattedResponse = mockVolatilityState.classification_description;
98100

99101
mockFetch.mockResolvedValueOnce({
102+
ok: true,
100103
json: () => Promise.resolve(mockVolatilityState),
101104
});
102105

packages/plugin-xtreamly/__tests__/libs/VolatilityAPI.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('VolatilityAPI library', () => {
4242
volatility: 0.111,
4343
};
4444
mockFetch.mockResolvedValueOnce({
45+
ok: true,
4546
json: () => Promise.resolve(mockResponse),
4647
});
4748

@@ -65,6 +66,7 @@ describe('VolatilityAPI library', () => {
6566
},
6667
];
6768
mockFetch.mockResolvedValueOnce({
69+
ok: true,
6870
json: () => Promise.resolve(mockResponse),
6971
});
7072

@@ -94,6 +96,7 @@ describe('VolatilityAPI library', () => {
9496
classification_description: 'This is midvol',
9597
};
9698
mockFetch.mockResolvedValueOnce({
99+
ok: true,
97100
json: () => Promise.resolve(mockResponse),
98101
});
99102

@@ -118,6 +121,7 @@ describe('VolatilityAPI library', () => {
118121
},
119122
];
120123
mockFetch.mockResolvedValueOnce({
124+
ok: true,
121125
json: () => Promise.resolve(mockResponse),
122126
});
123127

packages/plugin-xtreamly/src/libs/VolatilityAPI.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class VolatilityAPI extends XtreamlyAPI {
3636
startDate: Date,
3737
endDate: Date,
3838
symbol = 'ETH'
39-
): Promise<VolatilityPrediction[]> {
39+
): Promise<StatePrediction[]> {
4040
return this.get(XtreamlyAPIPath.stateHistorical, {
4141
symbol,
4242
start_date: startDate.getTime(),

packages/plugin-xtreamly/src/libs/XtreamlyAPI.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ export class XtreamlyAPI {
3838
return fetch(url.toString(), {
3939
method: 'GET',
4040
headers: this.headers,
41-
}).then((res) => res.json());
41+
}).then(async (res) => {
42+
if (!res.ok) {
43+
throw new Error(`HTTP error! status: ${res.status}`);
44+
}
45+
return res.json();
46+
});
4247
}
4348

4449
async is_ok(): Promise<boolean> {

0 commit comments

Comments
 (0)