laplace-api 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +37 -0
- package/.github/workflows/test.yml +25 -0
- package/README.md +461 -2
- package/package.json +1 -1
- package/src/client/broker.ts +9 -7
- package/src/client/capital_increase.ts +7 -12
- package/src/client/collections.ts +57 -28
- package/src/client/financial_fundamentals.ts +2 -5
- package/src/client/financial_ratios.ts +114 -95
- package/src/client/live-price-web-socket.ts +84 -11
- package/src/client/live-price.ts +204 -77
- package/src/client/politician.ts +75 -0
- package/src/client/stocks.ts +73 -0
- package/src/test/broker.test.ts +583 -148
- package/src/test/capital_increase.test.ts +186 -39
- package/src/test/collections.test.ts +445 -60
- package/src/test/custom_theme.test.ts +242 -60
- package/src/test/financial_fundamentals.test.ts +297 -56
- package/src/test/financial_ratios.test.ts +363 -92
- package/src/test/funds.test.ts +275 -68
- package/src/test/key-insight.test.ts +81 -19
- package/src/test/live-price.test.ts +425 -64
- package/src/test/politician.test.ts +253 -0
- package/src/test/readme.test.ts +483 -0
- package/src/test/search.test.ts +301 -65
- package/src/test/stocks.test.ts +764 -152
- package/src/utilities/configuration.ts +23 -10
- package/src/utilities/test.env +2 -2
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import "./client_test_suite";
|
|
4
|
+
import { Region, Locale } from "../client/collections";
|
|
5
|
+
import {
|
|
6
|
+
StockClient,
|
|
7
|
+
AssetClass,
|
|
8
|
+
HistoricalPricePeriod,
|
|
9
|
+
HistoricalPriceInterval,
|
|
10
|
+
} from "../client/stocks";
|
|
11
|
+
import { CollectionClient } from "../client/collections";
|
|
12
|
+
import { FundsClient, HistoricalFundPricePeriod } from "../client/funds";
|
|
13
|
+
import {
|
|
14
|
+
FinancialClient,
|
|
15
|
+
HistoricalRatiosKey,
|
|
16
|
+
RatioComparisonPeerType,
|
|
17
|
+
} from "../client/financial_ratios";
|
|
18
|
+
import {
|
|
19
|
+
FinancialFundamentalsClient,
|
|
20
|
+
TopMoverDirection,
|
|
21
|
+
} from "../client/financial_fundamentals";
|
|
22
|
+
import { AssetType } from "../client/stocks";
|
|
23
|
+
import { LivePriceClient } from "../client/live-price";
|
|
24
|
+
import { BrokerClient, BrokerSort, SortDirection } from "../client/broker";
|
|
25
|
+
import { SearchClient, SearchType } from "../client/search";
|
|
26
|
+
import {
|
|
27
|
+
LivePriceWebSocketClient,
|
|
28
|
+
LivePriceFeed,
|
|
29
|
+
} from "../client/live-price-web-socket";
|
|
30
|
+
import { CapitalIncreaseClient } from "../client/capital_increase";
|
|
31
|
+
import { CustomThemeClient, CollectionStatus } from "../client/custom_theme";
|
|
32
|
+
import { KeyInsightClient } from "../client/key-insights";
|
|
33
|
+
import { LaplaceHTTPError } from "../client/errors";
|
|
34
|
+
|
|
35
|
+
describe("README Examples - Comprehensive Tests", () => {
|
|
36
|
+
let stockClient: StockClient;
|
|
37
|
+
let collectionClient: CollectionClient;
|
|
38
|
+
let fundsClient: FundsClient;
|
|
39
|
+
let financialClient: FinancialClient;
|
|
40
|
+
let financialFundamentalsClient: FinancialFundamentalsClient;
|
|
41
|
+
let livePriceClient: LivePriceClient;
|
|
42
|
+
let brokerClient: BrokerClient;
|
|
43
|
+
let searchClient: SearchClient;
|
|
44
|
+
let webSocketClient: LivePriceWebSocketClient;
|
|
45
|
+
let capitalIncreaseClient: CapitalIncreaseClient;
|
|
46
|
+
let customThemeClient: CustomThemeClient;
|
|
47
|
+
let keyInsightClient: KeyInsightClient;
|
|
48
|
+
|
|
49
|
+
beforeAll(() => {
|
|
50
|
+
const config = (global as any).testSuite.config as LaplaceConfiguration;
|
|
51
|
+
const logger: Logger = {
|
|
52
|
+
info: jest.fn(),
|
|
53
|
+
error: jest.fn(),
|
|
54
|
+
warn: jest.fn(),
|
|
55
|
+
debug: jest.fn(),
|
|
56
|
+
} as unknown as Logger;
|
|
57
|
+
|
|
58
|
+
// Initialize all clients
|
|
59
|
+
stockClient = new StockClient(config, logger);
|
|
60
|
+
collectionClient = new CollectionClient(config, logger);
|
|
61
|
+
fundsClient = new FundsClient(config, logger);
|
|
62
|
+
financialClient = new FinancialClient(config, logger);
|
|
63
|
+
financialFundamentalsClient = new FinancialFundamentalsClient(
|
|
64
|
+
config,
|
|
65
|
+
logger
|
|
66
|
+
);
|
|
67
|
+
livePriceClient = new LivePriceClient(config, logger);
|
|
68
|
+
brokerClient = new BrokerClient(config, logger);
|
|
69
|
+
searchClient = new SearchClient(config, logger);
|
|
70
|
+
webSocketClient = new LivePriceWebSocketClient(
|
|
71
|
+
[LivePriceFeed.LiveBist, LivePriceFeed.LiveUs],
|
|
72
|
+
"test-user-id",
|
|
73
|
+
config,
|
|
74
|
+
logger
|
|
75
|
+
);
|
|
76
|
+
capitalIncreaseClient = new CapitalIncreaseClient(config, logger);
|
|
77
|
+
customThemeClient = new CustomThemeClient(config, logger);
|
|
78
|
+
keyInsightClient = new KeyInsightClient(config, logger);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("Stocks Client", () => {
|
|
82
|
+
test("getAllStocks with pagination", async () => {
|
|
83
|
+
const stocks = await stockClient.getAllStocks(Region.Us, 1, 10);
|
|
84
|
+
expect(Array.isArray(stocks)).toBe(true);
|
|
85
|
+
if (stocks.length > 0) {
|
|
86
|
+
expect(typeof stocks[0].id).toBe("string");
|
|
87
|
+
expect(typeof stocks[0].symbol).toBe("string");
|
|
88
|
+
expect(typeof stocks[0].name).toBe("string");
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("getStockDetailBySymbol", async () => {
|
|
93
|
+
const stock = await stockClient.getStockDetailBySymbol(
|
|
94
|
+
"AAPL",
|
|
95
|
+
AssetClass.Equity,
|
|
96
|
+
Region.Us,
|
|
97
|
+
Locale.En
|
|
98
|
+
);
|
|
99
|
+
expect(stock).toBeDefined();
|
|
100
|
+
expect(typeof stock.name).toBe("string");
|
|
101
|
+
expect(typeof stock.description).toBe("string");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("getStockDetailByID", async () => {
|
|
105
|
+
// Using a valid ID format
|
|
106
|
+
const stock = await stockClient.getStockDetailById(
|
|
107
|
+
"648ab66e38daf3102a5a7401",
|
|
108
|
+
Locale.En
|
|
109
|
+
);
|
|
110
|
+
expect(stock).toBeDefined();
|
|
111
|
+
expect(typeof stock.id).toBe("string");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("getHistoricalPrices", async () => {
|
|
115
|
+
const prices = await stockClient.getHistoricalPrices(
|
|
116
|
+
["THYAO"],
|
|
117
|
+
Region.Tr,
|
|
118
|
+
[HistoricalPricePeriod.OneDay, HistoricalPricePeriod.OneWeek]
|
|
119
|
+
);
|
|
120
|
+
expect(Array.isArray(prices)).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("getCustomHistoricalPrices", async () => {
|
|
124
|
+
const prices = await stockClient.getCustomHistoricalPrices(
|
|
125
|
+
"THYAO",
|
|
126
|
+
Region.Tr,
|
|
127
|
+
"2024-01-01",
|
|
128
|
+
"2024-01-10",
|
|
129
|
+
HistoricalPriceInterval.OneMinute,
|
|
130
|
+
true
|
|
131
|
+
);
|
|
132
|
+
expect(Array.isArray(prices)).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("getTickRules", async () => {
|
|
136
|
+
const rules = await stockClient.getTickRules("THYAO", Region.Tr);
|
|
137
|
+
expect(rules).toBeDefined();
|
|
138
|
+
expect(typeof rules.basePrice).toBe("number");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("getStockRestrictions", async () => {
|
|
142
|
+
const restrictions = await stockClient.getStockRestrictions(
|
|
143
|
+
"THYAO",
|
|
144
|
+
Region.Tr
|
|
145
|
+
);
|
|
146
|
+
expect(Array.isArray(restrictions)).toBe(true);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe("Collections Client", () => {
|
|
151
|
+
test("getAllCollections", async () => {
|
|
152
|
+
const collections = await collectionClient.getAllCollections(
|
|
153
|
+
Region.Tr,
|
|
154
|
+
Locale.En
|
|
155
|
+
);
|
|
156
|
+
expect(Array.isArray(collections)).toBe(true);
|
|
157
|
+
if (collections.length > 0) {
|
|
158
|
+
expect(typeof collections[0].id).toBe("string");
|
|
159
|
+
expect(typeof collections[0].title).toBe("string");
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("getCollectionDetail", async () => {
|
|
164
|
+
const detail = await collectionClient.getCollectionDetail(
|
|
165
|
+
"620f455a0187ade00bb0d55f",
|
|
166
|
+
Region.Tr,
|
|
167
|
+
Locale.En
|
|
168
|
+
);
|
|
169
|
+
expect(detail).toBeDefined();
|
|
170
|
+
expect(typeof detail.id).toBe("string");
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("getAllThemes", async () => {
|
|
174
|
+
const themes = await collectionClient.getAllThemes(Region.Tr, Locale.En);
|
|
175
|
+
expect(Array.isArray(themes)).toBe(true);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("getThemeDetail", async () => {
|
|
179
|
+
const themeDetail = await collectionClient.getThemeDetail(
|
|
180
|
+
"620f455a0187ade00bb0d55f",
|
|
181
|
+
Region.Tr,
|
|
182
|
+
Locale.En
|
|
183
|
+
);
|
|
184
|
+
expect(themeDetail).toBeDefined();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("getAllIndustries", async () => {
|
|
188
|
+
const industries = await collectionClient.getAllIndustries(
|
|
189
|
+
Region.Tr,
|
|
190
|
+
Locale.En
|
|
191
|
+
);
|
|
192
|
+
expect(Array.isArray(industries)).toBe(true);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("getIndustryDetail", async () => {
|
|
196
|
+
const industryDetail = await collectionClient.getIndustryDetail(
|
|
197
|
+
"65533e441fa5c7b58afa0957",
|
|
198
|
+
Region.Tr,
|
|
199
|
+
Locale.En
|
|
200
|
+
);
|
|
201
|
+
expect(industryDetail).toBeDefined();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("getAllSectors", async () => {
|
|
205
|
+
const sectors = await collectionClient.getAllSectors(
|
|
206
|
+
Region.Tr,
|
|
207
|
+
Locale.En
|
|
208
|
+
);
|
|
209
|
+
expect(Array.isArray(sectors)).toBe(true);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("getSectorDetail", async () => {
|
|
213
|
+
const sectorDetail = await collectionClient.getSectorDetail(
|
|
214
|
+
"65533e047844ee7afe9941bf",
|
|
215
|
+
Region.Tr,
|
|
216
|
+
Locale.En
|
|
217
|
+
);
|
|
218
|
+
expect(sectorDetail).toBeDefined();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("Funds Client", () => {
|
|
223
|
+
test("getFunds", async () => {
|
|
224
|
+
const funds = await fundsClient.getFunds(Region.Tr, 1, 10);
|
|
225
|
+
expect(Array.isArray(funds)).toBe(true);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("getFundStats", async () => {
|
|
229
|
+
const stats = await fundsClient.getFundStats("fund-symbol", Region.Tr);
|
|
230
|
+
expect(stats).toBeDefined();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("getFundDistribution", async () => {
|
|
234
|
+
const distribution = await fundsClient.getFundDistribution(
|
|
235
|
+
"fund-symbol",
|
|
236
|
+
Region.Tr
|
|
237
|
+
);
|
|
238
|
+
expect(distribution).toBeDefined();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("getHistoricalFundPrices", async () => {
|
|
242
|
+
const prices = await fundsClient.getHistoricalFundPrices(
|
|
243
|
+
"fund-symbol",
|
|
244
|
+
Region.Tr,
|
|
245
|
+
HistoricalFundPricePeriod.OneYear
|
|
246
|
+
);
|
|
247
|
+
expect(Array.isArray(prices)).toBe(true);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe("Financial Data Client", () => {
|
|
252
|
+
test("getHistoricalRatios", async () => {
|
|
253
|
+
const ratios = await financialClient.getHistoricalRatios(
|
|
254
|
+
"THYAO",
|
|
255
|
+
[HistoricalRatiosKey.PriceToEarningsRatio],
|
|
256
|
+
Region.Tr,
|
|
257
|
+
Locale.En
|
|
258
|
+
);
|
|
259
|
+
expect(Array.isArray(ratios)).toBe(true);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("getFinancialRatioComparison", async () => {
|
|
263
|
+
const comparisons = await financialClient.getFinancialRatioComparison(
|
|
264
|
+
"TUPRS",
|
|
265
|
+
Region.Tr,
|
|
266
|
+
RatioComparisonPeerType.Sector
|
|
267
|
+
);
|
|
268
|
+
expect(comparisons).toBeDefined();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test("getStockDividends", async () => {
|
|
272
|
+
const dividends = await financialFundamentalsClient.getStockDividends(
|
|
273
|
+
"AAPL",
|
|
274
|
+
Region.Us
|
|
275
|
+
);
|
|
276
|
+
expect(Array.isArray(dividends)).toBe(true);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("getStockStats", async () => {
|
|
280
|
+
const stats = await financialFundamentalsClient.getStockStats(
|
|
281
|
+
["AAPL", "GOOGL"],
|
|
282
|
+
Region.Us
|
|
283
|
+
);
|
|
284
|
+
expect(Array.isArray(stats)).toBe(true);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("getTopMovers", async () => {
|
|
288
|
+
const movers = await financialFundamentalsClient.getTopMovers(
|
|
289
|
+
Region.Tr,
|
|
290
|
+
1,
|
|
291
|
+
10,
|
|
292
|
+
TopMoverDirection.Gainers,
|
|
293
|
+
AssetType.Stock,
|
|
294
|
+
AssetClass.Equity
|
|
295
|
+
);
|
|
296
|
+
expect(Array.isArray(movers)).toBe(true);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe("Live Price Client", () => {
|
|
301
|
+
test("getLivePriceForBIST", async () => {
|
|
302
|
+
const bistClient = livePriceClient.getLivePriceForBIST([
|
|
303
|
+
"THYAO",
|
|
304
|
+
"GARAN",
|
|
305
|
+
]);
|
|
306
|
+
expect(bistClient).toBeDefined();
|
|
307
|
+
expect(typeof bistClient.receive).toBe("function");
|
|
308
|
+
expect(typeof bistClient.close).toBe("function");
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("getLivePriceForUS", async () => {
|
|
312
|
+
const usClient = livePriceClient.getLivePriceForUS(["AAPL", "GOOGL"]);
|
|
313
|
+
expect(usClient).toBeDefined();
|
|
314
|
+
expect(typeof usClient.receive).toBe("function");
|
|
315
|
+
expect(typeof usClient.close).toBe("function");
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
describe("Brokers Client", () => {
|
|
320
|
+
test("getBrokers", async () => {
|
|
321
|
+
const brokers = await brokerClient.getBrokers(Region.Tr, 1, 10);
|
|
322
|
+
expect(Array.isArray(brokers.items)).toBe(true);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("getMarketStocks", async () => {
|
|
326
|
+
const marketStocks = await brokerClient.getMarketStocks(
|
|
327
|
+
Region.Tr,
|
|
328
|
+
BrokerSort.NetAmount,
|
|
329
|
+
SortDirection.Desc,
|
|
330
|
+
"2024-01-01",
|
|
331
|
+
"2024-01-31",
|
|
332
|
+
1,
|
|
333
|
+
10
|
|
334
|
+
);
|
|
335
|
+
expect(Array.isArray(marketStocks.items)).toBe(true);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test("getBrokersByStock", async () => {
|
|
339
|
+
const brokersByStock = await brokerClient.getBrokersByStock(
|
|
340
|
+
"THYAO",
|
|
341
|
+
Region.Tr,
|
|
342
|
+
BrokerSort.NetAmount,
|
|
343
|
+
SortDirection.Desc,
|
|
344
|
+
"2024-01-01",
|
|
345
|
+
"2024-01-31",
|
|
346
|
+
1,
|
|
347
|
+
10
|
|
348
|
+
);
|
|
349
|
+
expect(Array.isArray(brokersByStock.items)).toBe(true);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
describe("Search Client", () => {
|
|
354
|
+
test("search", async () => {
|
|
355
|
+
const results = await searchClient.search(
|
|
356
|
+
"technology",
|
|
357
|
+
[SearchType.Stock, SearchType.Collection],
|
|
358
|
+
Region.Us,
|
|
359
|
+
Locale.En
|
|
360
|
+
);
|
|
361
|
+
expect(results).toBeDefined();
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
describe("WebSocket Client", () => {
|
|
366
|
+
test("connect", async () => {
|
|
367
|
+
// Test WebSocket connection functionality
|
|
368
|
+
expect(webSocketClient).toBeDefined();
|
|
369
|
+
expect(typeof webSocketClient.connect).toBe("function");
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
describe("Capital Increase Client", () => {
|
|
374
|
+
test("getAllCapitalIncreases", async () => {
|
|
375
|
+
const increases = await capitalIncreaseClient.getAllCapitalIncreases(
|
|
376
|
+
1,
|
|
377
|
+
10,
|
|
378
|
+
Region.Tr
|
|
379
|
+
);
|
|
380
|
+
expect(Array.isArray(increases.items)).toBe(true);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
test("getCapitalIncreasesForInstrument", async () => {
|
|
384
|
+
const instrumentIncreases =
|
|
385
|
+
await capitalIncreaseClient.getCapitalIncreasesForInstrument(
|
|
386
|
+
"THYAO",
|
|
387
|
+
1,
|
|
388
|
+
10,
|
|
389
|
+
Region.Tr
|
|
390
|
+
);
|
|
391
|
+
expect(Array.isArray(instrumentIncreases.items)).toBe(true);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test("getActiveRightsForInstrument", async () => {
|
|
395
|
+
const rights = await capitalIncreaseClient.getActiveRightsForInstrument(
|
|
396
|
+
"THYAO",
|
|
397
|
+
"2024-01-15",
|
|
398
|
+
Region.Tr
|
|
399
|
+
);
|
|
400
|
+
expect(Array.isArray(rights)).toBe(true);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
describe("Custom Themes Client", () => {
|
|
405
|
+
test("getAllCustomThemes", async () => {
|
|
406
|
+
const themes = await customThemeClient.getAllCustomThemes(Locale.En);
|
|
407
|
+
expect(Array.isArray(themes)).toBe(true);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
test("getCustomThemeDetail", async () => {
|
|
411
|
+
const themeDetail = await customThemeClient.getCustomThemeDetail(
|
|
412
|
+
"685d0912119e32929b8006ac",
|
|
413
|
+
Locale.En,
|
|
414
|
+
null
|
|
415
|
+
);
|
|
416
|
+
expect(themeDetail).toBeDefined();
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test("createCustomTheme", async () => {
|
|
420
|
+
const stockID = "648ab66e38daf3102a5a7401";
|
|
421
|
+
const id = await customThemeClient.createCustomTheme({
|
|
422
|
+
title: { en: "My Tech Portfolio" },
|
|
423
|
+
description: { en: "Technology stocks portfolio" },
|
|
424
|
+
region: [Region.Us],
|
|
425
|
+
stocks: [stockID],
|
|
426
|
+
status: CollectionStatus.Active,
|
|
427
|
+
});
|
|
428
|
+
expect(typeof id).toBe("string");
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("updateCustomTheme", async () => {
|
|
432
|
+
const themeID = "620f455a0187ade00bb0d55f";
|
|
433
|
+
const stockID = "648ab66e38daf3102a5a7401";
|
|
434
|
+
await expect(
|
|
435
|
+
customThemeClient.updateCustomTheme(themeID, {
|
|
436
|
+
title: { en: "Updated Tech Portfolio" },
|
|
437
|
+
stockIds: [stockID],
|
|
438
|
+
})
|
|
439
|
+
).resolves.not.toThrow();
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
test("deleteCustomTheme", async () => {
|
|
443
|
+
const themeID = "620f455a0187ade00bb0d55f";
|
|
444
|
+
await expect(
|
|
445
|
+
customThemeClient.deleteCustomTheme(themeID)
|
|
446
|
+
).resolves.not.toThrow();
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
describe("Key Insights Client", () => {
|
|
451
|
+
test("getKeyInsights", async () => {
|
|
452
|
+
const insights = await keyInsightClient.getKeyInsights("AAPL", Region.Us);
|
|
453
|
+
expect(insights).toBeDefined();
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
describe("Error Handling", () => {
|
|
458
|
+
test("should handle invalid API key", async () => {
|
|
459
|
+
const invalidConfig = new LaplaceConfiguration({
|
|
460
|
+
baseURL: "https://api.laplace.com",
|
|
461
|
+
apiKey: "invalid-key",
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const logger: Logger = {
|
|
465
|
+
info: jest.fn(),
|
|
466
|
+
error: jest.fn(),
|
|
467
|
+
warn: jest.fn(),
|
|
468
|
+
debug: jest.fn(),
|
|
469
|
+
} as unknown as Logger;
|
|
470
|
+
|
|
471
|
+
const invalidClient = new StockClient(invalidConfig, logger);
|
|
472
|
+
|
|
473
|
+
await expect(
|
|
474
|
+
invalidClient.getStockDetailBySymbol(
|
|
475
|
+
"INVALID",
|
|
476
|
+
AssetClass.Equity,
|
|
477
|
+
Region.Us,
|
|
478
|
+
Locale.En
|
|
479
|
+
)
|
|
480
|
+
).rejects.toThrow(LaplaceHTTPError);
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
});
|