@@ -55,47 +55,27 @@ describe('Plotly.toImage', function() {
55
55
56
56
it ( 'should throw error with unsupported file type' , function ( done ) {
57
57
var fig = Lib . extendDeep ( { } , subplotMock ) ;
58
- var errors = [ ] ;
59
58
60
59
Plotly . plot ( gd , fig . data , fig . layout )
61
60
. then ( function ( gd ) {
62
- try {
63
- Plotly . toImage ( gd , { format : 'x' } ) ;
64
- } catch ( e ) {
65
- errors . push ( e . message ) ;
66
- }
67
- } )
68
- . then ( function ( ) {
69
- expect ( errors . length ) . toBe ( 1 ) ;
70
- expect ( errors [ 0 ] ) . toBe ( 'Image format is not jpeg, png, svg or webp.' ) ;
61
+ expect ( function ( ) { Plotly . toImage ( gd , { format : 'x' } ) ; } )
62
+ . toThrow ( new Error ( 'Image format is not jpeg, png, svg or webp.' ) ) ;
71
63
} )
72
64
. catch ( fail )
73
65
. then ( done ) ;
74
66
} ) ;
75
67
76
68
it ( 'should throw error with height and/or width < 1' , function ( done ) {
77
69
var fig = Lib . extendDeep ( { } , subplotMock ) ;
78
- var errors = [ ] ;
79
70
80
71
Plotly . plot ( gd , fig . data , fig . layout )
81
72
. then ( function ( ) {
82
- try {
83
- Plotly . toImage ( gd , { height : 0.5 } ) ;
84
- } catch ( e ) {
85
- errors . push ( e . message ) ;
86
- }
87
- } )
88
- . then ( function ( ) {
89
- try {
90
- Plotly . toImage ( gd , { width : 0.5 } ) ;
91
- } catch ( e ) {
92
- errors . push ( e . message ) ;
93
- }
73
+ expect ( function ( ) { Plotly . toImage ( gd , { height : 0.5 } ) ; } )
74
+ . toThrow ( new Error ( 'Height and width should be pixel values.' ) ) ;
94
75
} )
95
76
. then ( function ( ) {
96
- expect ( errors . length ) . toBe ( 2 ) ;
97
- expect ( errors [ 0 ] ) . toBe ( 'Height and width should be pixel values.' ) ;
98
- expect ( errors [ 1 ] ) . toBe ( 'Height and width should be pixel values.' ) ;
77
+ expect ( function ( ) { Plotly . toImage ( gd , { width : 0.5 } ) ; } )
78
+ . toThrow ( new Error ( 'Height and width should be pixel values.' ) ) ;
99
79
} )
100
80
. catch ( fail )
101
81
. then ( done ) ;
0 commit comments