summaryrefslogtreecommitdiff
path: root/tests/FundLab.Web.Tests/ChartTests.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 22:43:26 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 22:43:26 +0800
commit12c4d3625458c830a2746a1f277fb684e9c498cb (patch)
tree5e1d9f7751c54eda81e805fe9deef0fc7e749430 /tests/FundLab.Web.Tests/ChartTests.fs
parent4c60174fc66927db5536bc2fe06574c753140055 (diff)
downloadfund-lab-12c4d3625458c830a2746a1f277fb684e9c498cb.tar.gz
Add returns and charts slice (3d-9b)
Diffstat (limited to 'tests/FundLab.Web.Tests/ChartTests.fs')
-rw-r--r--tests/FundLab.Web.Tests/ChartTests.fs47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/FundLab.Web.Tests/ChartTests.fs b/tests/FundLab.Web.Tests/ChartTests.fs
index cede2d2..0382b0a 100644
--- a/tests/FundLab.Web.Tests/ChartTests.fs
+++ b/tests/FundLab.Web.Tests/ChartTests.fs
@@ -21,3 +21,50 @@ module ChartTests =
Assert.Equal(1.0, points[1].y)
Assert.Equal(0.4, points[2].y)
Assert.Equal("2026-01-03", points[2].navDate)
+
+ [<Fact>]
+ let ``series points keep the shared date axis and normalize each series`` () =
+ let dates = [ "2026-01-01"; "2026-01-02"; "2026-01-03" ]
+
+ let values =
+ [
+ "2026-01-01", "100.00"
+ "2026-01-02", "150.00"
+ "2026-01-03", "125.00"
+ ]
+
+ let points = Chart.seriesPoints dates values
+
+ Assert.Equal(3, points.Length)
+ Assert.Equal(0.0, points[0].x)
+ Assert.Equal(0.5, points[1].x)
+ Assert.Equal(1.0, points[2].x)
+ Assert.Equal(0.0, points[0].y)
+ Assert.Equal(1.0, points[1].y)
+ Assert.Equal(0.5, points[2].y)
+ Assert.Equal("150.00", points[1].value)
+
+ [<Fact>]
+ let ``series points skip missing dates instead of filling zero`` () =
+ let dates = [ "2026-01-01"; "2026-01-02"; "2026-01-03" ]
+
+ let values =
+ [
+ "2026-01-01", "100.00"
+ "2026-01-03", "125.00"
+ ]
+
+ let points = Chart.seriesPoints dates values
+
+ Assert.Equal(2, points.Length)
+ Assert.Equal(0.0, points[0].x)
+ Assert.Equal(1.0, points[1].x)
+ Assert.Equal("2026-01-03", points[1].label)
+
+ [<Fact>]
+ let ``a single point is centered and keeps no line`` () =
+ let points = Chart.seriesPoints [ "2026-01-01" ] [ "2026-01-01", "1.00000000" ]
+
+ Assert.Equal(1, points.Length)
+ Assert.Equal(0.5, points[0].x)
+ Assert.Equal(0.5, points[0].y)