diff --git a/src/stocks/netease/index.ts b/src/stocks/netease/index.ts index e4d90ca..022289e 100644 --- a/src/stocks/netease/index.ts +++ b/src/stocks/netease/index.ts @@ -89,11 +89,11 @@ const Netease: StockApi = { const items: Dictionary[] = 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; } diff --git a/test/stocks/netease/index.test.ts b/test/stocks/netease/index.test.ts index f97cf9c..cf7928f 100644 --- a/test/stocks/netease/index.test.ts +++ b/test/stocks/netease/index.test.ts @@ -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: "贵州茅台" })])); }); });