2020-07-22 01:07:10 +08:00
|
|
|
import NeteaseTransform from "../../../src/stocks/netease/transform";
|
2020-07-21 16:54:45 +08:00
|
|
|
|
|
|
|
describe("【网易】股票代码转换测试", () => {
|
|
|
|
it("深交所股票代码转换", async () => {
|
2020-07-23 01:33:07 +08:00
|
|
|
expect(() => (new NeteaseTransform()).SZExchangeTransform("000000"))
|
|
|
|
.toThrow(new Error("请检查股票代码是否正确"));
|
2020-07-21 16:54:45 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).SZExchangeTransform("SZ000000"))
|
|
|
|
.toBe("1000000");
|
2020-07-21 16:54:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("上交所股票代码转换", async () => {
|
2020-07-23 01:33:07 +08:00
|
|
|
expect(() => (new NeteaseTransform()).SHExchangeTransform("000000"))
|
|
|
|
.toThrow(new Error("请检查股票代码是否正确"));
|
2020-07-21 16:54:45 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).SHExchangeTransform("SH000000"))
|
|
|
|
.toBe("0000000");
|
2020-07-21 16:54:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("港交所股票代码转换", async () => {
|
2020-07-23 01:33:07 +08:00
|
|
|
expect(() => (new NeteaseTransform()).HKExchangeTransform("000000"))
|
|
|
|
.toThrow(new Error("请检查股票代码是否正确"));
|
2020-07-21 16:54:45 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).HKExchangeTransform("HK000000"))
|
|
|
|
.toBe("hk000000");
|
2020-07-21 16:54:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("美交所股票代码转换", async () => {
|
2020-07-23 01:33:07 +08:00
|
|
|
expect(() => (new NeteaseTransform()).USExchangeTransform("000000"))
|
|
|
|
.toThrow(new Error("请检查股票代码是否正确"));
|
2020-07-21 16:54:45 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).USExchangeTransform("US000000"))
|
|
|
|
.toBe("US_000000");
|
2020-07-21 16:54:45 +08:00
|
|
|
});
|
2020-07-22 10:21:39 +08:00
|
|
|
|
|
|
|
it("交易所股票代码转换", async () => {
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transform("SZ000000"))
|
|
|
|
.toBe("1000000");
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transform("SH000000"))
|
|
|
|
.toBe("0000000");
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transform("HK000000"))
|
|
|
|
.toBe("hk000000");
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transform("US000000"))
|
|
|
|
.toBe("US_000000");
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect(() => (new NeteaseTransform()).transform("000000"))
|
|
|
|
.toThrow(new Error("请检查股票代码是否正确"));
|
2020-07-22 10:21:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("交易所股票组代码转换", async () => {
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transforms(["SZ000000"]))
|
|
|
|
.toStrictEqual(["1000000"]);
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transforms(["SH000000"]))
|
|
|
|
.toStrictEqual(["0000000"]);
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transforms(["HK000000"]))
|
|
|
|
.toStrictEqual(["hk000000"]);
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect((new NeteaseTransform()).transforms(["US000000"]))
|
|
|
|
.toStrictEqual(["US_000000"]);
|
2020-07-22 10:21:39 +08:00
|
|
|
|
2020-07-23 01:33:07 +08:00
|
|
|
expect(() => (new NeteaseTransform()).transforms(["000000"]))
|
|
|
|
.toThrow(new Error("请检查股票代码是否正确"));
|
2020-07-22 10:21:39 +08:00
|
|
|
});
|
2020-07-21 16:54:45 +08:00
|
|
|
});
|