forked from plotly/Plotly.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleTests.fs
More file actions
54 lines (50 loc) · 2.32 KB
/
SimpleTests.fs
File metadata and controls
54 lines (50 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Tests.SimpleTests
open Expecto
open Plotly.NET
open Plotly.NET.LayoutObjects
open Plotly.NET.TraceObjects
open Plotly.NET.GenericChart
open TestUtils.HtmlCodegen
let simpleChart =
let xData = [0. .. 10.]
let yData = [0. .. 10.]
Chart.Point(xData, yData, UseDefaults = false)
|> Chart.withTitle "Hello world!"
|> Chart.withXAxisStyle ("xAxis", ShowGrid=false)
|> Chart.withYAxisStyle ("yAxis", ShowGrid=false)
[<Tests>]
let ``Html layout tests`` =
testList "SimpleTests.Simple tests" [
testCase "Expecting plotly js" ( fun () ->
"https://cdn.plot.ly/plotly-2.6.3.min"
|> chartGeneratedContains simpleChart
);
testCase "Expecting data" ( fun () ->
"""var data = [{"type":"scatter","mode":"markers","x":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],"y":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],"marker":{},"line":{}}];"""
|> chartGeneratedContains simpleChart
);
testCase "Expecting layout info" (fun () ->
"""var layout = {"title":{"text":"Hello world!"},"xaxis":{"title":{"text":"xAxis"},"showgrid":false},"yaxis":{"title":{"text":"yAxis"},"showgrid":false}};"""
|> chartGeneratedContains simpleChart
);
testCase "Expecting cloudflare link" (fun () ->
"\"https://cdnjs.cloudflare.com/ajax/libs/require.js"
|> chartGeneratedContains simpleChart
);
testCase "Expecting require config" (fun () ->
"var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.6.3.min'}}) || require;"
|> chartGeneratedContains simpleChart
);
testCase "Expecting html tags in embedded page only" (fun () ->
["<html>"; "</html>"; "<head>"; "</head>"; "<body>"; "</body>"; "<script type=\"text/javascript\">"; "</script>"]
|> substringListIsInChart simpleChart toEmbeddedHTML
);
testCase "Expecting some html tags in both embedded and not embedded" (fun () ->
["<script type=\"text/javascript\">"; "</script>"]
|> chartGeneratedContainsList simpleChart
);
testCase "Passing args to the function" ( fun () ->
"data, layout, config);"
|> chartGeneratedContains simpleChart
)
]