feat: 增加 腾讯搜索股票代码美股代码大写、增加 腾讯搜索股票代码测试用例

This commit is contained in:
zhangxiangliang 2020-08-24 00:08:19 +08:00
parent dcc491bd2a
commit 60bec3551b
2 changed files with 10 additions and 9 deletions

View File

@ -99,7 +99,7 @@ const Tencent: StockApi = {
case 'hk':
return COMMON_HK + code;
case 'us':
return COMMON_US + code.split('.')[0];
return COMMON_US + code.split('.')[0].toUpperCase();
default:
return '';
}

View File

@ -31,19 +31,20 @@ describe("【腾讯】股票代码接口", () => {
});
it("搜索股票代码", async () => {
await expect(Tencent.searchStocks("510500"))
.resolves
.toMatchObject([{ code: "SH510500", name: "500ETF" }]);
await expect(Tencent.searchStocks("苹果"))
await expect(Tencent.searchStocks("格力电器"))
.resolves
.toMatchObject([{ code: "USaapl", name: "苹果" }]);
.toMatchObject([{ code: "SZ000651", name: "格力电器" }]);
await expect(Tencent.searchStocks("腾讯控股"))
await expect(Tencent.searchStocks("贵州茅台"))
.resolves
.toMatchObject([{ code: "SH600519", name: "贵州茅台" }]);
await expect(Tencent.searchStocks("安踏体育"))
.resolves
.toMatchObject([
{ code: expect.stringMatching("[HK00700|UStcehy]"), name: expect.stringMatching("腾讯控股") },
{ code: expect.stringMatching("[HK00700|UStcehy]"), name: expect.stringMatching("腾讯控股") },
{ code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") },
{ code: expect.stringMatching(".*[02020|ANPDY].*"), name: expect.stringMatching(".*[安踏体育|\-].*") },
]);
});
});