@@ -6,7 +6,7 @@ open Plotly.NET.LayoutObjects
66open Plotly.NET .ConfigObjects
77open DynamicObj
88
9- open TestUtils.LayoutObjects
9+ open TestUtils.Objects
1010
1111let config =
1212 Config.init(
@@ -94,4 +94,48 @@ let ``Config json tests`` =
9494 testCase " globalTransforms" ( fun _ -> config |> jsonFieldIsSetWith " globalTransforms" " \" function(x) => {return x}\" " )
9595 testCase " locale" ( fun _ -> config |> jsonFieldIsSetWith " locale" " \" de-DE\" " )
9696 testCase " locales" ( fun _ -> config |> jsonFieldIsSetWith " locales" """ {"yes":"no"}""" )
97+ ]
98+
99+
100+ let combined =
101+ Config.combine
102+ ( Config.init(
103+ ModeBarButtonsToRemove = [ StyleParam.ModeBarButton.AutoScale2d],
104+ ModeBarButtonsToAdd = [ StyleParam.ModeBarButton.DrawCircle],
105+ ModeBarButtons = [[ StyleParam.ModeBarButton.DrawClosedPath; StyleParam.ModeBarButton.DrawOpenPath]]
106+ ))
107+ ( Config.init(
108+ ModeBarButtonsToRemove = [ StyleParam.ModeBarButton.DrawCircle],
109+ ModeBarButtonsToAdd = [ StyleParam.ModeBarButton.AutoScale2d],
110+ ModeBarButtons = [[ StyleParam.ModeBarButton.OrbitRotation]]
111+ ))
112+
113+ let expectedCombined =
114+ Config.init(
115+ ModeBarButtonsToRemove = [ StyleParam.ModeBarButton.AutoScale2d; StyleParam.ModeBarButton.DrawCircle],
116+ ModeBarButtonsToAdd = [ StyleParam.ModeBarButton.DrawCircle; StyleParam.ModeBarButton.AutoScale2d],
117+ ModeBarButtons = [[ StyleParam.ModeBarButton.DrawClosedPath; StyleParam.ModeBarButton.DrawOpenPath];[ StyleParam.ModeBarButton.OrbitRotation]]
118+ )
119+
120+ [<Tests>]
121+ let ``Config API tests`` =
122+ testList " ConfigObjects.Config API" [
123+ testCase " combine ModeBarButtonsToRemove" ( fun _ ->
124+ Expect.sequenceEqual
125+ ( combined.TryGetTypedValue< seq< string>>( " modeBarButtonsToRemove" )) .Value
126+ ( expectedCombined.TryGetTypedValue< seq< string>>( " modeBarButtonsToRemove" )) .Value
127+ " Config.combine did not return the correct object"
128+ )
129+ testCase " combine ModeBarButtonsToAdd" ( fun _ ->
130+ Expect.sequenceEqual
131+ ( combined.TryGetTypedValue< seq< string>>( " modeBarButtonsToAdd" )) .Value
132+ ( expectedCombined.TryGetTypedValue< seq< string>>( " modeBarButtonsToAdd" )) .Value
133+ " Config.combine did not return the correct object"
134+ )
135+ testCase " combine ModeBarButtons" ( fun _ ->
136+ Expect.sequenceEqual
137+ ( Seq.concat ( combined.TryGetTypedValue< seq< seq< string>>>( " modeBarButtons" )) .Value)
138+ ( Seq.concat ( expectedCombined.TryGetTypedValue< seq< seq< string>>>( " modeBarButtons" )) .Value)
139+ " Config.combine did not return the correct object"
140+ )
97141 ]
0 commit comments