@@ -24,16 +24,19 @@ describe('PlotlyService', () => {
24
24
25
25
it ( 'should check the plotly dependency' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
26
26
( PlotlyService as any ) . plotly = undefined ;
27
- expect ( ( ) => service . getPlotly ( ) ) . toThrowError ( `Peer dependency plotly.js isn't installed` ) ;
28
- PlotlyService . setPlotly ( PlotlyJS ) ;
27
+
28
+ return service . getPlotly ( ) . catch ( err => {
29
+ expect ( err . message ) . toBe ( `Peer dependency plotly.js isn't installed` ) ;
30
+ PlotlyService . setPlotly ( PlotlyJS ) ;
31
+ } ) ;
29
32
} ) ) ;
30
33
31
34
it ( 'should be created' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
32
35
expect ( service ) . toBeTruthy ( ) ;
33
36
} ) ) ;
34
37
35
- it ( 'should return the plotly object' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
36
- expect ( service . getPlotly ( ) ) . toBe ( PlotlyJS ) ;
38
+ it ( 'should return the plotly object' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
39
+ expect ( await service . getPlotly ( ) ) . toBe ( PlotlyJS ) ;
37
40
} ) ) ;
38
41
39
42
it ( 'should set the module name' , ( ) => {
@@ -47,7 +50,7 @@ describe('PlotlyService', () => {
47
50
48
51
it ( 'should call plotly.newPlot method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
49
52
return new Promise < void > ( async ( resolve ) => {
50
- const plotly = service . getPlotly ( ) ;
53
+ const plotly = await ( service as any ) . getPlotly ( ) ;
51
54
PlotlyService . setPlotly ( 'waiting' ) ;
52
55
53
56
setTimeout ( ( ) => PlotlyService . setPlotly ( PlotlyJS ) , 100 ) ;
@@ -62,8 +65,8 @@ describe('PlotlyService', () => {
62
65
} ) ;
63
66
} ) ) ;
64
67
65
- it ( 'should call plotly.plot method' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
66
- const plotly = service . getPlotly ( ) ;
68
+ it ( 'should call plotly.plot method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
69
+ const plotly = await service . getPlotly ( ) ;
67
70
68
71
spyOn ( plotly , 'plot' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
69
72
service . plot ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
@@ -73,8 +76,8 @@ describe('PlotlyService', () => {
73
76
expect ( plotly . plot ) . toHaveBeenCalledWith ( 'one' , { data : 'two' , layout : 'three' , config : 'four' , frames : 'five' } ) ;
74
77
} ) ) ;
75
78
76
- it ( 'should call plotly.update method' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
77
- const plotly = service . getPlotly ( ) ;
79
+ it ( 'should call plotly.update method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
80
+ const plotly = await service . getPlotly ( ) ;
78
81
79
82
spyOn ( plotly , 'react' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
80
83
service . update ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
@@ -84,8 +87,8 @@ describe('PlotlyService', () => {
84
87
expect ( plotly . react ) . toHaveBeenCalledWith ( 'one' , { data : 'two' , layout : 'three' , config : 'four' , frames : 'five' } ) ;
85
88
} ) ) ;
86
89
87
- it ( 'should call plotly.Plots.resize method' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
88
- const plotly = service . getPlotly ( ) ;
90
+ it ( 'should call plotly.Plots.resize method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
91
+ const plotly = await service . getPlotly ( ) ;
89
92
90
93
spyOn ( plotly . Plots , 'resize' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
91
94
service . resize ( 'one' as any ) ;
0 commit comments