diff --git a/test/stocks/netease/index.test.ts b/test/stocks/netease/index.test.ts index cf7928f..a386e35 100644 --- a/test/stocks/netease/index.test.ts +++ b/test/stocks/netease/index.test.ts @@ -15,15 +15,15 @@ describe("【网易】股票代码接口", () => { it("需要获取的股票代码组", async () => { await expect(Netease.getStocks(["SH510500"])) .resolves - .toMatchObject([{ code: "SH510500", name: "500ETF" }]); - - await expect(Netease.getStocks([])) - .resolves - .toMatchObject([]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH510500", name: "500ETF" })])); await expect(Netease.getStocks(["SZ510500"])) .resolves - .toMatchObject([{ code: "SZ510500", name: "---" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ510500", name: "---" })])); + + await expect(Netease.getStocks([])) + .resolves + .toEqual([]); }); it("搜索股票代码", async () => { diff --git a/test/stocks/sina/index.test.ts b/test/stocks/sina/index.test.ts index 1715c0e..3ef0d3a 100644 --- a/test/stocks/sina/index.test.ts +++ b/test/stocks/sina/index.test.ts @@ -14,31 +14,31 @@ describe("【新浪】股票代码接口", () => { it("需要获取的股票代码组", async () => { await expect(Sina.getStocks(["SH510500"])) .resolves - .toMatchObject([{ code: "SH510500", name: "500ETF" }]); - - await expect(Sina.getStocks([])) - .resolves - .toMatchObject([]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH510500", name: "500ETF" })])); await expect(Sina.getStocks(["SZ510500"])) .resolves - .toMatchObject([{ code: "SZ510500", name: "---" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ510500", name: "---" })])); + + await expect(Sina.getStocks([])) + .resolves + .toEqual([]); }); it("搜索股票代码", async () => { await expect(Sina.searchStocks("格力电器")) .resolves - .toMatchObject([{ code: "SZ000651", name: "格力电器" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ000651", name: "格力电器" })])); await expect(Sina.searchStocks("贵州茅台")) .resolves - .toMatchObject([{ code: "SH600519", name: "贵州茅台" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH600519", name: "贵州茅台" })])); await expect(Sina.searchStocks("安踏体育")) .resolves - .toMatchObject([ - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - ]); + .toEqual(expect.arrayContaining([ + expect.objectContaining({ code: "HK02020", name: "安踏体育" }), + expect.objectContaining({ code: "USANPDF", name: "安踏" }), + ])); }); }); diff --git a/test/stocks/tencent/index.test.ts b/test/stocks/tencent/index.test.ts index 14d37d7..de30f48 100644 --- a/test/stocks/tencent/index.test.ts +++ b/test/stocks/tencent/index.test.ts @@ -19,32 +19,31 @@ describe("【腾讯】股票代码接口", () => { it("需要获取的股票代码组", async () => { await expect(Tencent.getStocks(["SH510500"])) .resolves - .toMatchObject([{ code: "SH510500", name: "500ETF" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH510500", name: "500ETF" })])); await expect(Tencent.getStocks(["SZ510500"])) .resolves - .toMatchObject([{ code: "SZ510500", name: "---" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ510500", name: "---" })])); await expect(Tencent.getStocks([])) .resolves - .toMatchObject([]); + .toEqual([]); }); it("搜索股票代码", async () => { - await expect(Tencent.searchStocks("格力电器")) .resolves - .toMatchObject([{ code: "SZ000651", name: "格力电器" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ000651", name: "格力电器" })])); await expect(Tencent.searchStocks("贵州茅台")) .resolves - .toMatchObject([{ code: "SH600519", name: "贵州茅台" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH600519", name: "贵州茅台" })])); await expect(Tencent.searchStocks("安踏体育")) .resolves - .toMatchObject([ - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - ]); + .toEqual(expect.arrayContaining([ + expect.objectContaining({ code: "HK02020", name: "安踏体育" }), + expect.objectContaining({ code: "USANPDY", name: "安踏体育" }), + ])); }); }); diff --git a/test/stocks/xueqiu/index.test.ts b/test/stocks/xueqiu/index.test.ts index 8a2a903..dec27f3 100644 --- a/test/stocks/xueqiu/index.test.ts +++ b/test/stocks/xueqiu/index.test.ts @@ -21,33 +21,31 @@ describe("【雪球】股票代码接口", () => { it("需要获取的股票代码组", async () => { await expect(Xueqiu.getStocks(["SH510500"])) .resolves - .toMatchObject([{ code: "SH510500", name: "中证500ETF" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH510500", name: "中证500ETF" })])); await expect(Xueqiu.getStocks(["SZ510500"])) .resolves - .toMatchObject([{ code: "SZ510500", name: "---" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ510500", name: "---" })])); await expect(Xueqiu.getStocks([])) .resolves - .toMatchObject([]); + .toEqual([]); }); it("搜索股票代码", async () => { await expect(Xueqiu.searchStocks("格力电器")) .resolves - .toMatchObject([{ code: "SZ000651", name: "格力电器" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SZ000651", name: "格力电器" })])); await expect(Xueqiu.searchStocks("贵州茅台")) .resolves - .toMatchObject([{ code: "SH600519", name: "贵州茅台" }]); + .toEqual(expect.arrayContaining([expect.objectContaining({ code: "SH600519", name: "贵州茅台" })])); await expect(Xueqiu.searchStocks("安踏体育")) .resolves - .toMatchObject([ - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - { code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") }, - ]); + .toEqual(expect.arrayContaining([ + expect.objectContaining({ code: "HK02020", name: "安踏体育" }), + expect.objectContaining({ code: "USANPDY", name: "安踏体育ADR" }), + ])); }); });