Skip to content

Commit 33fb8c1

Browse files
committed
use jasmine toThrow in extend tests
1 parent 63d8863 commit 33fb8c1

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

shelly/plotlyjs/static/plotlyjs/tests/extend_test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,15 @@ describe('extendFlat', function() {
204204
});
205205

206206
it('does not handle null inputs', function() {
207-
try { extendFlat(null, obj); }
208-
catch(err) {
209-
expect(err.toString().indexOf('TypeError:') !== 1).toBe(true);
210-
}
207+
expect(function() {
208+
extendFlat(null, obj);
209+
}).toThrowError(TypeError);
211210
});
212211

213212
it('does not handle string targets', function() {
214-
try { extendFlat('str', obj); }
215-
catch(err) {
216-
expect(err.toString().indexOf('TypeError:') !== 1).toBe(true);
217-
}
213+
expect(function() {
214+
extendFlat(null, obj);
215+
}).toThrowError(TypeError);
218216
});
219217
});
220218

@@ -398,13 +396,12 @@ describe('extendDeep', function() {
398396
var circ = { a: {b: null} };
399397
circ.a.b = circ;
400398

401-
try { extendDeep({}, circ); }
402-
catch(err) {
403-
expect(
404-
err.toString().indexOf('InternalError:') !== 1 || // firefox
405-
err.toString().indexOf('RangeError:') !== 1 // chrome
406-
).toBe(true);
407-
}
399+
expect(function() {
400+
extendDeep({}, circ);
401+
}).toThrow();
402+
403+
// results in an InternalError on Chrome and
404+
// a RangeError on Firefox
408405
});
409406
});
410407

0 commit comments

Comments
 (0)