mirror of
https://github.com/zhangxiangliang/stock-api.git
synced 2025-01-23 06:00:24 +08:00
feat: 修复 网易搜索代码输入为中文时报错、增加 网易搜索股票代码测试用例
This commit is contained in:
parent
0f7d20599f
commit
cafab0ca63
@ -89,11 +89,11 @@ const Netease: StockApi = {
|
||||
const items: Dictionary<string>[] = JSON.parse(row);
|
||||
|
||||
const codes: string[] = items.map(i => {
|
||||
if (i.tag.includes(COMMON_SZ)) {
|
||||
if (i.tag.includes(COMMON_SZ) || i.type.includes(COMMON_SZ)) {
|
||||
return COMMON_SZ + i.symbol;
|
||||
}
|
||||
|
||||
if (i.tag.includes(COMMON_SH)) {
|
||||
if (i.tag.includes(COMMON_SH) || i.type.includes(COMMON_SH)) {
|
||||
return COMMON_SH + i.symbol;
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,12 @@ describe("【网易】股票代码接口", () => {
|
||||
});
|
||||
|
||||
it("搜索股票代码", async () => {
|
||||
await expect(Netease.searchStocks("510500"))
|
||||
await expect(Netease.searchStocks("格力电器"))
|
||||
.resolves
|
||||
.toMatchObject([{ code: "SH510500", name: "500ETF" }]);
|
||||
.toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ000651", name: "格力电器" })]));
|
||||
|
||||
await expect(Netease.searchStocks("399001"))
|
||||
await expect(Netease.searchStocks("贵州茅台"))
|
||||
.resolves
|
||||
.toMatchObject([{ code: "SZ399001", name: "深证成指" }]);
|
||||
.toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH600519", name: "贵州茅台" })]));
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user