refactor: tighten types and reuse instrument UI
This commit is contained in:
@@ -59,13 +59,13 @@ describe("account position sections", () => {
|
||||
"bonds",
|
||||
"other",
|
||||
]);
|
||||
expect(sections[2].groups.map(group => group.positions[0].figi)).toEqual([
|
||||
expect(sections[2]?.groups.map(group => group.positions[0].figi)).toEqual([
|
||||
"FIGI-FUND",
|
||||
...otherTypes.map(type => `FIGI-${type}-NEXT`),
|
||||
]);
|
||||
expect(sections[0].groups[0].positions[0].shareText).toBe("40 %");
|
||||
expect(sections[1].groups[0].positions[0].shareText).toBe("20 %");
|
||||
expect(sections[2].groups[1].positions[0].shareText).toBe("20 %");
|
||||
expect(sections[0]?.groups[0]?.positions[0].shareText).toBe("40 %");
|
||||
expect(sections[1]?.groups[0]?.positions[0].shareText).toBe("20 %");
|
||||
expect(sections[2]?.groups[1]?.positions[0].shareText).toBe("20 %");
|
||||
expect(snapshot).toEqual(original);
|
||||
});
|
||||
|
||||
@@ -125,10 +125,10 @@ describe("account position sections", () => {
|
||||
figi: null,
|
||||
},
|
||||
{ ...second, figi: null },
|
||||
])[0].groups,
|
||||
])[0]?.groups,
|
||||
).toHaveLength(1);
|
||||
expect(
|
||||
sections([position, { ...second, figi: "OTHER-FIGI" }])[0].groups,
|
||||
sections([position, { ...second, figi: "OTHER-FIGI" }])[0]?.groups,
|
||||
).toHaveLength(2);
|
||||
expect(
|
||||
|
||||
@@ -143,19 +143,19 @@ describe("account position sections", () => {
|
||||
figi: null,
|
||||
isin: null,
|
||||
},
|
||||
])[0].groups,
|
||||
])[0]?.groups,
|
||||
).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("preserves one-account cards and does not merge repeated rows on the same account", () => {
|
||||
expect(
|
||||
sections([position, { ...second, account: position.account }])[0].groups,
|
||||
sections([position, { ...second, account: position.account }])[0]?.groups,
|
||||
).toHaveLength(2);
|
||||
expect(
|
||||
sections([
|
||||
{ ...position, account: undefined },
|
||||
{ ...second, account: undefined },
|
||||
])[0].groups,
|
||||
])[0]?.groups,
|
||||
).toHaveLength(2);
|
||||
});
|
||||
|
||||
@@ -170,9 +170,9 @@ describe("account position sections", () => {
|
||||
];
|
||||
|
||||
const before = structuredClone(source);
|
||||
const [group] = sections(source)[0].groups;
|
||||
const group = sections(source)[0]?.groups[0];
|
||||
expect(
|
||||
group.positions.map(item => [
|
||||
group?.positions.map(item => [
|
||||
item.quantity,
|
||||
item.currentValue,
|
||||
item.averagePurchasePrice,
|
||||
|
||||
Reference in New Issue
Block a user