laplace-api 3.0.1 → 4.0.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/package.json +1 -1
- package/src/client/broker.ts +175 -0
- package/src/client/capital_increase.ts +11 -11
- package/src/client/collections.ts +5 -13
- package/src/client/financial_fundamentals.ts +41 -33
- package/src/client/financial_ratios.ts +56 -35
- package/src/client/funds.ts +139 -0
- package/src/client/key-insights.ts +17 -0
- package/src/client/live-price.ts +25 -0
- package/src/client/stocks.ts +12 -2
- package/src/test/broker.test.ts +238 -0
- package/src/test/capital_increase.test.ts +119 -15
- package/src/test/collections.test.ts +69 -11
- package/src/test/custom_theme.test.ts +18 -9
- package/src/test/financial_fundamentals.test.ts +23 -8
- package/src/test/financial_ratios.test.ts +67 -37
- package/src/test/funds.test.ts +110 -0
- package/src/test/helpers.ts +58 -0
- package/src/test/key-insight.test.ts +48 -0
- package/src/test/live-price.test.ts +4 -5
- package/src/test/search.test.ts +71 -22
- package/src/test/stocks.test.ts +185 -67
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from "winston";
|
|
2
2
|
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
-
import { Client, createClient } from "../client/client";
|
|
4
3
|
import {
|
|
5
4
|
FinancialClient,
|
|
6
5
|
HistoricalRatiosKey,
|
|
@@ -8,12 +7,13 @@ import {
|
|
|
8
7
|
FinancialSheetPeriod,
|
|
9
8
|
Currency,
|
|
10
9
|
HistoricalFinancialSheetRow,
|
|
10
|
+
RatioComparisonPeerType,
|
|
11
11
|
} from "../client/financial_ratios";
|
|
12
|
-
import { Region, Locale } from "../client/collections";
|
|
13
12
|
import "./client_test_suite";
|
|
14
13
|
import { equal } from "assert";
|
|
14
|
+
import { Locale, Region } from "../client/collections";
|
|
15
15
|
|
|
16
|
-
describe(
|
|
16
|
+
describe("FinancialRatios", () => {
|
|
17
17
|
let financialClient: FinancialClient;
|
|
18
18
|
|
|
19
19
|
beforeAll(() => {
|
|
@@ -28,46 +28,78 @@ describe('FinancialRatios', () => {
|
|
|
28
28
|
financialClient = new FinancialClient(config, logger);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
test(
|
|
32
|
-
const resp = await financialClient.getFinancialRatioComparison(
|
|
33
|
-
expect(resp).not.toBeEmpty();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("GetHistoricalRatios", async () => {
|
|
37
|
-
const resp = await financialClient.getHistoricalRatios(
|
|
31
|
+
test("GetFinancialRatioComparison", async () => {
|
|
32
|
+
const resp = await financialClient.getFinancialRatioComparison(
|
|
38
33
|
"TUPRS",
|
|
39
|
-
Object.values(HistoricalRatiosKey).flat(),
|
|
40
34
|
Region.Tr,
|
|
41
|
-
|
|
35
|
+
RatioComparisonPeerType.Sector
|
|
42
36
|
);
|
|
43
37
|
expect(resp).not.toBeEmpty();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
expect(typeof ratio.items.at(0)?.sectorMean).toBe("number");
|
|
56
|
-
expect(typeof ratio.items.at(0)?.value).toBe("number");
|
|
57
|
-
}
|
|
38
|
+
|
|
39
|
+
const comparison = resp[0];
|
|
40
|
+
expect(typeof comparison.metricName).toBe("string");
|
|
41
|
+
expect(typeof comparison.normalizedValue).toBe("number");
|
|
42
|
+
|
|
43
|
+
const comparisonData = comparison.data;
|
|
44
|
+
expect(Array.isArray(comparisonData)).toBe(true);
|
|
45
|
+
expect(comparisonData).not.toBeEmpty();
|
|
46
|
+
expect(typeof comparisonData[0].slug).toBe("string");
|
|
47
|
+
expect(typeof comparisonData[0].value).toBe("number");
|
|
48
|
+
expect(typeof comparisonData[0].average).toBe("number");
|
|
58
49
|
});
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
describe("GetHistoricalRatios", () => {
|
|
52
|
+
test("GetHistoricalRatios", async () => {
|
|
53
|
+
const resp = await financialClient.getHistoricalRatios(
|
|
54
|
+
"TUPRS",
|
|
55
|
+
Object.values(HistoricalRatiosKey).flat(),
|
|
56
|
+
Region.Tr,
|
|
57
|
+
Locale.Tr
|
|
58
|
+
);
|
|
59
|
+
expect(resp).not.toBeEmpty();
|
|
60
|
+
|
|
61
|
+
const firstRatio = resp[0];
|
|
62
|
+
expect(typeof firstRatio.finalValue).toBe("number");
|
|
63
|
+
expect(typeof firstRatio.threeYearGrowth).toBe("number");
|
|
64
|
+
expect(typeof firstRatio.yearGrowth).toBe("number");
|
|
65
|
+
expect(typeof firstRatio.finalSectorValue).toBe("number");
|
|
66
|
+
expect(equal(firstRatio.currency, Currency.TRY));
|
|
67
|
+
expect(typeof firstRatio.format).toBe("string");
|
|
68
|
+
expect(typeof firstRatio.name).toBe("string");
|
|
69
|
+
|
|
70
|
+
expect(firstRatio.items).not.toBeEmpty();
|
|
71
|
+
const firstItem = firstRatio.items[0];
|
|
72
|
+
expect(typeof firstItem.period).toBe("string");
|
|
73
|
+
expect(typeof firstItem.sectorMean).toBe("number");
|
|
74
|
+
expect(typeof firstItem.value).toBe("number");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("GetHistoricalRatiosDescriptions", () => {
|
|
79
|
+
test("GetHistoricalRatiosDescriptions", async () => {
|
|
80
|
+
const resp = await financialClient.getHistoricalRatiosDescriptions(
|
|
81
|
+
Locale.Tr,
|
|
82
|
+
Region.Tr
|
|
83
|
+
);
|
|
84
|
+
expect(resp).not.toBeEmpty();
|
|
85
|
+
|
|
86
|
+
const firstDescription = resp[0];
|
|
87
|
+
expect(typeof firstDescription.id).toBe("number");
|
|
88
|
+
expect(typeof firstDescription.format).toBe("string");
|
|
89
|
+
expect(typeof firstDescription.currency).toBe("string");
|
|
90
|
+
expect(typeof firstDescription.slug).toBe("string");
|
|
91
|
+
expect(typeof firstDescription.createdAt).toBe("string");
|
|
92
|
+
expect(typeof firstDescription.updatedAt).toBe("string");
|
|
93
|
+
expect(typeof firstDescription.name).toBe("string");
|
|
94
|
+
expect(typeof firstDescription.description).toBe("string");
|
|
95
|
+
expect(typeof firstDescription.locale).toBe("string");
|
|
96
|
+
expect(typeof firstDescription.isRealtime).toBe("boolean");
|
|
97
|
+
});
|
|
66
98
|
});
|
|
67
99
|
|
|
68
|
-
test(
|
|
100
|
+
test("GetHistoricalFinancialSheets", async () => {
|
|
69
101
|
const resp = await financialClient.getHistoricalFinancialSheets(
|
|
70
|
-
|
|
102
|
+
"TUPRS",
|
|
71
103
|
{ year: 2022, month: 1, day: 1 },
|
|
72
104
|
{ year: 2025, month: 1, day: 1 },
|
|
73
105
|
FinancialSheetType.CashFlow,
|
|
@@ -88,7 +120,7 @@ describe('FinancialRatios', () => {
|
|
|
88
120
|
expect(firstSheet).toBeDefined();
|
|
89
121
|
|
|
90
122
|
expect(firstSheet.period).toBeDefined();
|
|
91
|
-
expect(typeof firstSheet.period).toBe("string")
|
|
123
|
+
expect(typeof firstSheet.period).toBe("string");
|
|
92
124
|
|
|
93
125
|
expect(firstSheet.items).toBeDefined();
|
|
94
126
|
expect(Array.isArray(firstSheet.items)).toBe(true);
|
|
@@ -102,8 +134,6 @@ describe('FinancialRatios', () => {
|
|
|
102
134
|
value: expect.any(Number),
|
|
103
135
|
lineCodeId: expect.any(Number),
|
|
104
136
|
indentLevel: expect.any(Number),
|
|
105
|
-
firstAncestorLineCodeId: expect.any(Number),
|
|
106
|
-
sectionLineCodeId: expect.any(Number),
|
|
107
137
|
});
|
|
108
138
|
});
|
|
109
139
|
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import "./client_test_suite";
|
|
4
|
+
import {
|
|
5
|
+
FundsClient,
|
|
6
|
+
FundType,
|
|
7
|
+
HistoricalFundPricePeriod,
|
|
8
|
+
} from "../client/funds";
|
|
9
|
+
import { Region } from "../client/collections";
|
|
10
|
+
|
|
11
|
+
describe("Funds Client", () => {
|
|
12
|
+
let client: FundsClient;
|
|
13
|
+
|
|
14
|
+
beforeAll(() => {
|
|
15
|
+
const config = (global as any).testSuite.config as LaplaceConfiguration;
|
|
16
|
+
const logger: Logger = {
|
|
17
|
+
info: jest.fn(),
|
|
18
|
+
error: jest.fn(),
|
|
19
|
+
warn: jest.fn(),
|
|
20
|
+
debug: jest.fn(),
|
|
21
|
+
} as unknown as Logger;
|
|
22
|
+
|
|
23
|
+
client = new FundsClient(config, logger);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("getFunds", () => {
|
|
27
|
+
test("should return funds list for TR region", async () => {
|
|
28
|
+
const resp = await client.getFunds(Region.Tr, 1, 10);
|
|
29
|
+
|
|
30
|
+
expect(resp).toBeDefined();
|
|
31
|
+
expect(Array.isArray(resp)).toBe(true);
|
|
32
|
+
expect(resp.length).toBeGreaterThan(0);
|
|
33
|
+
|
|
34
|
+
const fund = resp[0];
|
|
35
|
+
expect(typeof fund.symbol).toBe("string");
|
|
36
|
+
expect(typeof fund.name).toBe("string");
|
|
37
|
+
expect(typeof fund.assetType).toBe("string");
|
|
38
|
+
expect(typeof fund.managementFee).toBe("number");
|
|
39
|
+
expect(typeof fund.riskLevel).toBe("number");
|
|
40
|
+
expect(typeof fund.ownerSymbol).toBe("string");
|
|
41
|
+
expect(Object.values(FundType)).toContain(fund.fundType);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("should handle pagination correctly", async () => {
|
|
45
|
+
const page1 = await client.getFunds(Region.Tr, 1, 5);
|
|
46
|
+
|
|
47
|
+
expect(page1.length).toBeLessThanOrEqual(5);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("getFundStats", () => {
|
|
52
|
+
test("should return fund statistics", async () => {
|
|
53
|
+
const resp = await client.getFundStats("SPP", Region.Tr);
|
|
54
|
+
|
|
55
|
+
expect(resp).toBeDefined();
|
|
56
|
+
expect(typeof resp.yearBeta).toBe("number");
|
|
57
|
+
expect(typeof resp.yearStdev).toBe("number");
|
|
58
|
+
expect(typeof resp.ytdReturn).toBe("number");
|
|
59
|
+
expect(typeof resp.yearMomentum).toBe("number");
|
|
60
|
+
expect(typeof resp.yearlyReturn).toBe("number");
|
|
61
|
+
expect(typeof resp.monthlyReturn).toBe("number");
|
|
62
|
+
expect(typeof resp.fiveYearReturn).toBe("number");
|
|
63
|
+
expect(typeof resp.sixMonthReturn).toBe("number");
|
|
64
|
+
expect(typeof resp.threeYearReturn).toBe("number");
|
|
65
|
+
expect(typeof resp.threeMonthReturn).toBe("number");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("should handle invalid fund symbol", async () => {
|
|
69
|
+
await expect(
|
|
70
|
+
client.getFundStats("INVALID_FUND", Region.Tr)
|
|
71
|
+
).rejects.toThrow();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("getFundDistribution", () => {
|
|
76
|
+
test("should return fund asset distribution", async () => {
|
|
77
|
+
const resp = await client.getFundDistribution("SPP", Region.Tr);
|
|
78
|
+
|
|
79
|
+
expect(resp).toBeDefined();
|
|
80
|
+
expect(Array.isArray(resp.categories)).toBe(true);
|
|
81
|
+
|
|
82
|
+
if (resp.categories.length > 0) {
|
|
83
|
+
const distribution = resp.categories[0];
|
|
84
|
+
expect(distribution.category).toBeDefined();
|
|
85
|
+
expect(typeof distribution.percentage).toBe("number");
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("getHistoricalFundPrices", () => {
|
|
91
|
+
test("should return historical prices", async () => {
|
|
92
|
+
const resp = await client.getHistoricalFundPrices(
|
|
93
|
+
"SPP",
|
|
94
|
+
Region.Tr,
|
|
95
|
+
HistoricalFundPricePeriod.OneMonth
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(resp).toBeDefined();
|
|
99
|
+
expect(Array.isArray(resp)).toBe(true);
|
|
100
|
+
expect(resp.length).toBeGreaterThan(0);
|
|
101
|
+
|
|
102
|
+
const pricePoint = resp[0];
|
|
103
|
+
expect(typeof pricePoint.price).toBe("number");
|
|
104
|
+
expect(typeof pricePoint.aum).toBe("number");
|
|
105
|
+
expect(pricePoint.date).toBeDefined();
|
|
106
|
+
expect(typeof pricePoint.shareCount).toBe("number");
|
|
107
|
+
expect(typeof pricePoint.investorCount).toBe("number");
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Collection, CollectionDetail } from "../client/collections";
|
|
2
|
+
|
|
3
|
+
export const validateCollection = (collection: Collection) => {
|
|
4
|
+
expect(typeof collection.id).toBe("string");
|
|
5
|
+
expect(typeof collection.title).toBe("string");
|
|
6
|
+
expect(typeof collection.imageUrl).toBe("string");
|
|
7
|
+
expect(typeof collection.avatarUrl).toBe("string");
|
|
8
|
+
expect(typeof collection.numStocks).toBe("number");
|
|
9
|
+
|
|
10
|
+
if (collection.description !== undefined) {
|
|
11
|
+
expect(typeof collection.description).toBe("string");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (collection.region !== undefined) {
|
|
15
|
+
expect(Array.isArray(collection.region)).toBe(true);
|
|
16
|
+
collection.region.forEach(region => {
|
|
17
|
+
expect(typeof region).toBe("string");
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (collection.assetClass !== undefined) {
|
|
22
|
+
expect(typeof collection.assetClass).toBe("string");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (collection.image !== undefined) {
|
|
26
|
+
expect(typeof collection.image).toBe("string");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (collection.order !== undefined) {
|
|
30
|
+
expect(typeof collection.order).toBe("number");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (collection.status !== undefined) {
|
|
34
|
+
expect(typeof collection.status).toBe("string");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (collection.metaData !== undefined) {
|
|
38
|
+
expect(typeof collection.metaData).toBe("object");
|
|
39
|
+
expect(collection.metaData).not.toBeNull();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const validateCollectionDetail = (collectionDetail: CollectionDetail) => {
|
|
44
|
+
validateCollection(collectionDetail);
|
|
45
|
+
|
|
46
|
+
expect(Array.isArray(collectionDetail.stocks)).toBe(true);
|
|
47
|
+
expect(collectionDetail.stocks.length).toBeGreaterThan(0);
|
|
48
|
+
|
|
49
|
+
const firstStock = collectionDetail.stocks[0];
|
|
50
|
+
expect(typeof firstStock.id).toBe("string");
|
|
51
|
+
expect(typeof firstStock.assetType).toBe("string");
|
|
52
|
+
expect(typeof firstStock.name).toBe("string");
|
|
53
|
+
expect(typeof firstStock.symbol).toBe("string");
|
|
54
|
+
expect(typeof firstStock.sectorId).toBe("string");
|
|
55
|
+
expect(typeof firstStock.industryId).toBe("string");
|
|
56
|
+
expect(typeof firstStock.updatedDate).toBe("string");
|
|
57
|
+
expect(typeof firstStock.active).toBe("boolean");
|
|
58
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import "./client_test_suite";
|
|
4
|
+
import { KeyInsightClient } from "../client/key-insights";
|
|
5
|
+
import { Region } from "../client/collections";
|
|
6
|
+
|
|
7
|
+
describe("Key Insight", () => {
|
|
8
|
+
let client: KeyInsightClient;
|
|
9
|
+
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
const config = (global as any).testSuite.config as LaplaceConfiguration;
|
|
12
|
+
const logger: Logger = {
|
|
13
|
+
info: jest.fn(),
|
|
14
|
+
error: jest.fn(),
|
|
15
|
+
warn: jest.fn(),
|
|
16
|
+
debug: jest.fn(),
|
|
17
|
+
} as unknown as Logger;
|
|
18
|
+
|
|
19
|
+
client = new KeyInsightClient(config, logger);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("getKeyInsights", () => {
|
|
23
|
+
test("should return key insights for valid symbol", async () => {
|
|
24
|
+
const resp = await client.getKeyInsights("TOASO", Region.Tr);
|
|
25
|
+
|
|
26
|
+
expect(resp).toBeDefined();
|
|
27
|
+
expect(resp.insight).toBeDefined();
|
|
28
|
+
expect(resp.insight.length).toBeGreaterThan(0);
|
|
29
|
+
expect(resp.symbol).toBe("TOASO");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("should handle invalid symbol gracefully", async () => {
|
|
33
|
+
await expect(
|
|
34
|
+
client.getKeyInsights("INVALID_SYMBOL", Region.Tr)
|
|
35
|
+
).rejects.toThrow();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("should work with US region", async () => {
|
|
39
|
+
const resp = await client.getKeyInsights("AAPL", Region.Us);
|
|
40
|
+
expect(resp).toBeDefined();
|
|
41
|
+
expect(resp.symbol).toBe("AAPL");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("should handle empty symbol", async () => {
|
|
45
|
+
await expect(client.getKeyInsights("", Region.Tr)).rejects.toThrow();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from "winston";
|
|
2
2
|
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
-
import { Region } from "../client/collections";
|
|
4
3
|
import "./client_test_suite";
|
|
5
4
|
import { LivePriceClient } from "../client/live-price";
|
|
6
5
|
import {
|
|
@@ -16,8 +15,8 @@ describe("LivePrice", () => {
|
|
|
16
15
|
let ws: LivePriceWebSocketClient;
|
|
17
16
|
|
|
18
17
|
const TEST_CONSTANTS = {
|
|
19
|
-
JEST_TIMEOUT:
|
|
20
|
-
MAIN_TIMEOUT:
|
|
18
|
+
JEST_TIMEOUT: 15000,
|
|
19
|
+
MAIN_TIMEOUT: 10000,
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
beforeAll(async () => {
|
|
@@ -67,7 +66,7 @@ describe("LivePrice", () => {
|
|
|
67
66
|
}
|
|
68
67
|
);
|
|
69
68
|
|
|
70
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
69
|
+
await new Promise((resolve) => setTimeout(resolve, TEST_CONSTANTS.MAIN_TIMEOUT));
|
|
71
70
|
|
|
72
71
|
for (const symbol of symbols) {
|
|
73
72
|
const symbolData = receivedData.filter(
|
|
@@ -100,7 +99,7 @@ describe("LivePrice", () => {
|
|
|
100
99
|
}
|
|
101
100
|
);
|
|
102
101
|
|
|
103
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
102
|
+
await new Promise((resolve) => setTimeout(resolve, TEST_CONSTANTS.MAIN_TIMEOUT));
|
|
104
103
|
|
|
105
104
|
for (const symbol of symbols) {
|
|
106
105
|
const symbolData = receivedData.filter(
|
package/src/test/search.test.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Logger } from
|
|
2
|
-
import { LaplaceConfiguration } from
|
|
3
|
-
import { SearchClient, SearchType } from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import { SearchClient, SearchType } from "../client/search";
|
|
4
|
+
import "./client_test_suite";
|
|
5
|
+
import { Region, Locale } from "../client/collections";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
describe('Search', () => {
|
|
7
|
+
describe("Search", () => {
|
|
9
8
|
let client: SearchClient;
|
|
10
9
|
|
|
11
10
|
beforeAll(() => {
|
|
@@ -21,23 +20,73 @@ describe('Search', () => {
|
|
|
21
20
|
client = new SearchClient(config, logger);
|
|
22
21
|
});
|
|
23
22
|
|
|
24
|
-
test(
|
|
25
|
-
const resp = await client.search(
|
|
26
|
-
|
|
23
|
+
test("SearchStock", async () => {
|
|
24
|
+
const resp = await client.search(
|
|
25
|
+
"TUPRS",
|
|
26
|
+
[SearchType.Stock],
|
|
27
|
+
Region.Tr,
|
|
28
|
+
Locale.Tr
|
|
29
|
+
);
|
|
30
|
+
expect(resp.stocks).not.toBeEmpty();
|
|
31
|
+
|
|
32
|
+
const firstResult = resp.stocks[0];
|
|
33
|
+
expect(typeof firstResult.id).toBe("string");
|
|
34
|
+
expect(typeof firstResult.name).toBe("string");
|
|
35
|
+
expect(typeof firstResult.title).toBe("string");
|
|
36
|
+
expect(typeof firstResult.region).toBe("string");
|
|
37
|
+
expect(typeof firstResult.assetType).toBe("string");
|
|
38
|
+
expect(typeof firstResult.type).toBe("string");
|
|
27
39
|
});
|
|
28
40
|
|
|
29
|
-
test(
|
|
30
|
-
const resp = await client.search(
|
|
31
|
-
|
|
41
|
+
test("SearchIndustry", async () => {
|
|
42
|
+
const resp = await client.search(
|
|
43
|
+
"Hava",
|
|
44
|
+
[SearchType.Industry],
|
|
45
|
+
Region.Tr,
|
|
46
|
+
Locale.Tr
|
|
47
|
+
);
|
|
48
|
+
expect(resp.industries).not.toBeEmpty();
|
|
49
|
+
|
|
50
|
+
const firstResult = resp.industries[0];
|
|
51
|
+
expect(typeof firstResult.id).toBe("string");
|
|
52
|
+
expect(typeof firstResult.title).toBe("string");
|
|
53
|
+
expect(Array.isArray(firstResult.region)).toBe(true);
|
|
54
|
+
expect(firstResult.region.length).toBeGreaterThan(0);
|
|
55
|
+
firstResult.region.forEach((region) => {
|
|
56
|
+
expect(typeof region).toBe("string");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(typeof firstResult.assetClass).toBe("string");
|
|
60
|
+
expect(typeof firstResult.imageUrl).toBe("string");
|
|
61
|
+
expect(typeof firstResult.avatarUrl).toBe("string");
|
|
32
62
|
});
|
|
63
|
+
test("SearchAllTypes", async () => {
|
|
64
|
+
const resp = await client.search(
|
|
65
|
+
"Ab",
|
|
66
|
+
[
|
|
67
|
+
SearchType.Stock,
|
|
68
|
+
SearchType.Industry,
|
|
69
|
+
SearchType.Sector,
|
|
70
|
+
SearchType.Collection,
|
|
71
|
+
],
|
|
72
|
+
Region.Us,
|
|
73
|
+
Locale.Tr
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
expect(typeof resp).toBe("object");
|
|
77
|
+
expect(resp).not.toBeNull();
|
|
78
|
+
|
|
79
|
+
const hasResults =
|
|
80
|
+
(resp.stocks && resp.stocks.length > 0) ||
|
|
81
|
+
(resp.industries && resp.industries.length > 0) ||
|
|
82
|
+
(resp.sectors && resp.sectors.length > 0) ||
|
|
83
|
+
(resp.collections && resp.collections.length > 0);
|
|
84
|
+
|
|
85
|
+
expect(hasResults).toBe(true);
|
|
33
86
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
SearchType.Sector,
|
|
39
|
-
SearchType.Collection
|
|
40
|
-
], Region.Us, Locale.Tr);
|
|
41
|
-
expect(resp).not.toBeEmpty();
|
|
87
|
+
if (resp.stocks) expect(Array.isArray(resp.stocks)).toBe(true);
|
|
88
|
+
if (resp.industries) expect(Array.isArray(resp.industries)).toBe(true);
|
|
89
|
+
if (resp.sectors) expect(Array.isArray(resp.sectors)).toBe(true);
|
|
90
|
+
if (resp.collections) expect(Array.isArray(resp.collections)).toBe(true);
|
|
42
91
|
});
|
|
43
|
-
});
|
|
92
|
+
});
|