@@ -9,6 +9,67 @@ import {connectTraceToPlot} from 'lib';
9
9
describe ( 'TraceSelector' , ( ) => {
10
10
const TraceSection = connectTraceToPlot ( Section ) ;
11
11
12
+ it ( 'sets mode to markers if trace scatter, no data or mode provided' , ( ) => {
13
+ const editorProps = {
14
+ ...fixtures . scatter ( { data : [ { mode : null , xsrc : null , ysrc : null } ] } ) ,
15
+ onUpdate : jest . fn ( ) ,
16
+ } ;
17
+ const wrapper = mount (
18
+ < TestEditor { ...editorProps } plotly = { plotly } >
19
+ < TraceSection traceIndex = { 0 } >
20
+ < TraceSelector attr = "type" />
21
+ </ TraceSection >
22
+ </ TestEditor >
23
+ ) . find ( TraceSelector ) ;
24
+
25
+ const innerDropdown = wrapper . find ( Dropdown ) ;
26
+
27
+ expect ( wrapper . props ( ) . plotProps . container . mode ) . toBe ( 'markers' ) ;
28
+ expect ( innerDropdown . prop ( 'value' ) ) . toEqual ( 'scatter' ) ;
29
+ } ) ;
30
+
31
+ it ( 'if no data provided, but mode is provided, displays correct trace type' , ( ) => {
32
+ const editorProps = {
33
+ ...fixtures . scatter ( {
34
+ data : [ { mode : 'lines+markers' , xsrc : null , ysrc : null } ] ,
35
+ } ) ,
36
+ onUpdate : jest . fn ( ) ,
37
+ } ;
38
+ const wrapper = mount (
39
+ < TestEditor { ...editorProps } plotly = { plotly } >
40
+ < TraceSection traceIndex = { 0 } >
41
+ < TraceSelector attr = "type" />
42
+ </ TraceSection >
43
+ </ TestEditor >
44
+ ) . find ( TraceSelector ) ;
45
+
46
+ const innerDropdown = wrapper . find ( Dropdown ) ;
47
+
48
+ expect ( innerDropdown . prop ( 'value' ) ) . toEqual ( 'line' ) ;
49
+ } ) ;
50
+
51
+ it ( 'if data provided, but no mode is provided, chooses mode according to fullData' , ( ) => {
52
+ const editorProps = {
53
+ ...fixtures . scatter ( ) ,
54
+ onUpdate : jest . fn ( ) ,
55
+ } ;
56
+
57
+ expect ( ! editorProps . graphDiv . data [ 0 ] . mode ) . toBe ( true ) ;
58
+ expect ( editorProps . graphDiv . _fullData [ 0 ] . mode ) . toBe ( 'lines+markers' ) ;
59
+
60
+ const wrapper = mount (
61
+ < TestEditor { ...editorProps } plotly = { plotly } >
62
+ < TraceSection traceIndex = { 0 } >
63
+ < TraceSelector attr = "type" />
64
+ </ TraceSection >
65
+ </ TestEditor >
66
+ ) . find ( TraceSelector ) ;
67
+
68
+ const innerDropdown = wrapper . find ( Dropdown ) ;
69
+ expect ( wrapper . props ( ) . plotProps . container . mode ) . toBe ( 'lines+markers' ) ;
70
+ expect ( innerDropdown . prop ( 'value' ) ) . toEqual ( 'line' ) ;
71
+ } ) ;
72
+
12
73
it ( 'interprets scatter + fill as type=area' , ( ) => {
13
74
const editorProps = {
14
75
...fixtures . scatter ( { data : [ { fill : 'tonexty' } ] } ) ,
0 commit comments