Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43a6150

Browse files
committed
lint (use toThrow, instead of error msg comparison)
1 parent 22a598b commit 43a6150

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

test/jasmine/tests/toimage_test.js

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,47 +55,27 @@ describe('Plotly.toImage', function() {
5555

5656
it('should throw error with unsupported file type', function(done) {
5757
var fig = Lib.extendDeep({}, subplotMock);
58-
var errors = [];
5958

6059
Plotly.plot(gd, fig.data, fig.layout)
6160
.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.'));
7163
})
7264
.catch(fail)
7365
.then(done);
7466
});
7567

7668
it('should throw error with height and/or width < 1', function(done) {
7769
var fig = Lib.extendDeep({}, subplotMock);
78-
var errors = [];
7970

8071
Plotly.plot(gd, fig.data, fig.layout)
8172
.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.'));
9475
})
9576
.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.'));
9979
})
10080
.catch(fail)
10181
.then(done);

0 commit comments

Comments
 (0)