summaryrefslogtreecommitdiff
path: root/tests/FundLab.Web.Tests/ChartTests.fs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/FundLab.Web.Tests/ChartTests.fs')
-rw-r--r--tests/FundLab.Web.Tests/ChartTests.fs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/FundLab.Web.Tests/ChartTests.fs b/tests/FundLab.Web.Tests/ChartTests.fs
new file mode 100644
index 0000000..cede2d2
--- /dev/null
+++ b/tests/FundLab.Web.Tests/ChartTests.fs
@@ -0,0 +1,23 @@
+namespace FundLab.Web.Tests
+
+open Xunit
+open FundLab.Web
+
+module ChartTests =
+
+ [<Fact>]
+ let ``chart points preserve chronological order and normalize NAV values`` () =
+ let observations : NavObservation list =
+ [
+ { navDate = "2026-01-01"; nav = "1.00000000"; dailyReturn = None }
+ { navDate = "2026-01-02"; nav = "1.25000000"; dailyReturn = Some "25.00000000" }
+ { navDate = "2026-01-03"; nav = "1.10000000"; dailyReturn = Some "-12.00000000" }
+ ]
+
+ let points = Chart.chartPoints observations
+
+ Assert.Equal(3, points.Length)
+ Assert.Equal(0.0, points[0].x)
+ Assert.Equal(1.0, points[1].y)
+ Assert.Equal(0.4, points[2].y)
+ Assert.Equal("2026-01-03", points[2].navDate)