Skip to content

Commit 36c59cd

Browse files
committed
Fix two failing assert.throws.
Since smash.load uses a separate context, any exceptions it throws use a different Error class, and thus the assert.throws fails. So, instead, just allow any exception type to be thrown.
1 parent e1842fc commit 36c59cd

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

test/selection/data-test.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ suite.addBatch({
4242
assert.deepEqual(body.data(), [data]);
4343
assert.strictEqual(body.data()[0], data);
4444
},
45-
// TODO not sure why Node is not catching this error:
46-
"throws an error if data is null or undefined": function(body) {
47-
assert.throws(function() { body.data(null); }, Error);
48-
assert.throws(function() { body.data(function() {}); }, Error);
45+
"throws an error if data is null": function(body) {
46+
var errored;
47+
try { body.data(null); } catch (e) { errored = true; }
48+
assert.isTrue(errored);
49+
},
50+
"throws an error if data is a function that returns null": function(body) {
51+
var errored;
52+
try { body.data(function() {}); } catch (e) { errored = true; }
53+
assert.isTrue(errored);
4954
}
5055
}
5156
}
@@ -83,10 +88,15 @@ suite.addBatch({
8388
"returns a new selection": function(div) {
8489
assert.isFalse(div.data([0, 1]) === div);
8590
},
86-
// TODO not sure why Node is not catching this error:
87-
"throws an error if data is null or undefined": function(div) {
88-
assert.throws(function() { div.data(null); }, Error);
89-
assert.throws(function() { div.data(function() {}); }, Error);
91+
"throws an error if data is null": function(div) {
92+
var errored;
93+
try { div.data(null); } catch (e) { errored = true; }
94+
assert.isTrue(errored);
95+
},
96+
"throws an error if data is a function that returns null": function(div) {
97+
var errored;
98+
try { div.data(function() {}); } catch (e) { errored = true; }
99+
assert.isTrue(errored);
90100
},
91101
"with no arguments, returns an array of data": function(div) {
92102
var a = new Object(), b = new Object(), actual = [];

0 commit comments

Comments
 (0)