Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 43a6150

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

File tree

Expand file treeCollapse file tree

1 file changed

+6
-26
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-26
lines changed

‎test/jasmine/tests/toimage_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/toimage_test.js
+6-26Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.