@@ -2,6 +2,7 @@ using PlotlyLight
2
2
using PlotlyLight: settings
3
3
using Cobweb
4
4
using Cobweb: h
5
+ using JSON3: JSON3
5
6
using Test
6
7
using Aqua
7
8
@@ -30,20 +31,51 @@ html(x) = repr("text/html", x)
30
31
p4 (;x= 1 : 10 , y= 1 : 10 )
31
32
@test length (p4. data) == 3
32
33
@test p4. data[2 ] == p4. data[3 ]
34
+
35
+ p5 = p (p2 (p3 (p4)))
36
+ @test length (p5. data) == 6
33
37
end
34
38
35
39
@testset " plot" begin
36
40
@test_warn " `scatter` does not have attribute `X`" plot. scatter (X= 1 : 10 );
37
41
@test_nowarn plot. scatter (x= 1 : 10 );
42
+ @test contains (JSON3. write (plot (y= 1 : 10 )), " scatter" )
38
43
end
39
44
40
45
@testset " settings" begin
41
46
@test PlotlyLight. settings. layout == Config ()
42
47
@test PlotlyLight. settings. config == Config (; responsive= true )
43
48
end
44
49
50
+ @testset " saving" begin
51
+ dir = mktempdir ()
52
+ path1 = joinpath (dir, " test.html" )
53
+ path2 = joinpath (dir, " test2.html" )
54
+ p = Plot (Config (x = 1 : 10 ))
55
+ PlotlyLight. save (p, path1)
56
+ PlotlyLight. save (path2, p)
57
+ @test isfile (path1)
58
+ @test isfile (path2)
59
+ end
60
+
45
61
@testset " other" begin
46
62
@test propertynames (Plot ()) isa Vector{Symbol}
63
+ @test all (x in propertynames (Plot ()) for x in propertynames (plot))
64
+ @test PlotlyLight. fix_matrix ([1 2 ; 3 4 ]) == [[1 , 2 ], [3 , 4 ]]
65
+ @test propertynames (JSON3. read (JSON3. write (Plot ()))) == [:data , :layout , :config ]
66
+ end
67
+
68
+ @testset " show/display" begin
69
+ s = sprint ((io, x) -> show (io, MIME (" juliavscode/html" ), x), Plot ())
70
+ end
71
+
72
+ @testset " preset" begin
73
+ for f in PlotlyLight. preset. template
74
+ f ()
75
+ end
76
+ for f in PlotlyLight. preset. source
77
+ f ()
78
+ end
47
79
end
48
80
49
81
# -----------------------------------------------------------------------------# Aqua
0 commit comments