@@ -17,7 +17,9 @@ describe('index', () => {
17
17
echarts . instance . webview . postMessage = jest . fn ( ) ;
18
18
echarts . instance . clear ( ) ;
19
19
20
- expect ( echarts . instance . webview . postMessage ) . toBeCalledWith ( '{"types":"CLEAR"}' ) ;
20
+ expect ( echarts . instance . webview . postMessage ) . toBeCalledWith (
21
+ '{"types":"CLEAR"}' ,
22
+ ) ;
21
23
} ) ;
22
24
23
25
it ( 'getOption works' , ( ) => {
@@ -28,11 +30,13 @@ describe('index', () => {
28
30
echarts . instance . postMessage = jest . fn ( ) ;
29
31
echarts . instance . getOption ( ( ) => { } ) ;
30
32
31
- expect ( echarts . instance . postMessage ) . toBeCalledWith ( expect . objectContaining ( {
32
- properties : undefined ,
33
- types : 'GET_OPTION' ,
34
- uuid : expect . any ( String ) ,
35
- } ) ) ;
33
+ expect ( echarts . instance . postMessage ) . toBeCalledWith (
34
+ expect . objectContaining ( {
35
+ properties : undefined ,
36
+ types : 'GET_OPTION' ,
37
+ uuid : expect . any ( String ) ,
38
+ } ) ,
39
+ ) ;
36
40
} ) ;
37
41
38
42
it ( 'setOption works' , ( ) => {
@@ -43,16 +47,55 @@ describe('index', () => {
43
47
echarts . instance . postMessage = jest . fn ( ) ;
44
48
echarts . instance . setOption ( { test : '12345' } ) ;
45
49
46
- expect ( echarts . instance . postMessage ) . toBeCalledWith ( expect . objectContaining ( {
47
- payload : expect . objectContaining ( {
48
- lazyUpdate : false ,
49
- notMerge : false ,
50
- option : {
51
- test : '12345' ,
52
- } ,
50
+ expect ( echarts . instance . postMessage ) . toBeCalledWith (
51
+ expect . objectContaining ( {
52
+ payload : expect . objectContaining ( {
53
+ lazyUpdate : false ,
54
+ notMerge : false ,
55
+ option : {
56
+ test : '12345' ,
57
+ } ,
58
+ } ) ,
59
+ types : 'SET_OPTION' ,
53
60
} ) ,
54
- types : 'SET_OPTION' ,
55
- } ) ) ;
61
+ ) ;
62
+ } ) ;
63
+
64
+ it ( 'setBackgroundColor works' , ( ) => {
65
+ const jsx = < ECharts baseUrl = "something" backgroundColor = "red" /> ;
66
+ const renderer = render ( jsx ) ;
67
+ const echarts = renderer . getByType ( ECharts ) ;
68
+
69
+ echarts . instance . postMessage = jest . fn ( ) ;
70
+ echarts . instance . setBackgroundColor ( 'orange' ) ;
71
+ expect ( echarts . instance . postMessage ) . toBeCalledWith ( {
72
+ color : 'orange' ,
73
+ types : 'SET_BACKGROUND_COLOR' ,
74
+ } ) ;
75
+ } ) ;
76
+
77
+ it ( 'onMessage error' , ( ) => {
78
+ global . console = { log : jest . fn ( ) } ;
79
+
80
+ const jsx = < ECharts baseUrl = "something" /> ;
81
+ const renderer = render ( jsx ) ;
82
+
83
+ const echarts = renderer . getByType ( ECharts ) ;
84
+
85
+ echarts . instance . onMessage ( 'test' ) ;
86
+
87
+ expect ( console . log ) . toBeCalled ( ) ;
88
+ } ) ;
89
+
90
+ it ( 'no baseUrl works' , ( ) => {
91
+ jest . mock ( 'Platform' , ( ) => {
92
+ const Platform = require . requireActual ( 'Platform' ) ;
93
+ Platform . OS = 'android' ;
94
+ return Platform ;
95
+ } ) ;
96
+
97
+ const jsx = < ECharts /> ;
98
+ render ( jsx ) ;
56
99
} ) ;
57
100
58
101
it ( 'onMessage (CALLBACK) works' , ( ) => {
@@ -76,7 +119,9 @@ describe('index', () => {
76
119
} ,
77
120
} ) ;
78
121
79
- expect ( echarts . instance . callbacks [ '1234' ] ) . toBeCalledWith ( { somevalue : 'helloworld' } ) ;
122
+ expect ( echarts . instance . callbacks [ '1234' ] ) . toBeCalledWith ( {
123
+ somevalue : 'helloworld' ,
124
+ } ) ;
80
125
} ) ;
81
126
82
127
it ( 'onMessage (DATA) works' , ( ) => {
0 commit comments