Skip to content

Commit ddaac7f

Browse files
authored
Merge pull request #347 from Standard8/throws-with-expected-argument
Add expected arguments to assert.throws calls
2 parents 282ab0c + 02eb2f9 commit ddaac7f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

test/test-base64.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const base64 = require("../lib/base64");
1010
exports["test out of range encoding"] = function(assert) {
1111
assert.throws(function() {
1212
base64.encode(-1);
13-
});
13+
}, /Must be between 0 and 63/);
1414
assert.throws(function() {
1515
base64.encode(64);
16-
});
16+
}, /Must be between 0 and 63/);
1717
};
1818

1919
exports["test normal encoding and decoding"] = function(assert) {

test/test-source-map-generator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ exports["test adding mappings (invalid)"] = function(assert) {
8484
// Not enough info.
8585
assert.throws(function() {
8686
map.addMapping({});
87-
});
87+
}, /"generated" is a required argument/);
8888

8989
// Original file position, but no source.
9090
assert.throws(function() {
9191
map.addMapping({
9292
generated: { line: 1, column: 1 },
9393
original: { line: 1, column: 1 }
9494
});
95-
});
95+
}, /Invalid mapping/);
9696
};
9797

9898
exports["test adding mappings with skipValidation"] = function(assert) {
@@ -105,15 +105,15 @@ exports["test adding mappings with skipValidation"] = function(assert) {
105105
// Not enough info, caught by `util.getArgs`
106106
assert.throws(function() {
107107
map.addMapping({});
108-
});
108+
}, /"generated" is a required argument/);
109109

110110
// Original file position, but no source. Not checked.
111111
assert.doesNotThrow(function() {
112112
map.addMapping({
113113
generated: { line: 1, column: 1 },
114114
original: { line: 1, column: 1 }
115115
});
116-
});
116+
}, /Invalid mapping/);
117117
};
118118

119119
exports["test that the correct mappings are being generated"] = function(assert) {

test/test-source-node.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ exports["test .add()"] = function(assert) {
3535
// Adding other stuff doesn't.
3636
assert.throws(function() {
3737
node.add({});
38-
});
38+
}, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
3939
assert.throws(function() {
4040
node.add(function() {});
41-
});
41+
}, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
4242
};
4343

4444
exports["test .prepend()"] = function(assert) {
@@ -70,10 +70,10 @@ exports["test .prepend()"] = function(assert) {
7070
// Prepending other stuff doesn't.
7171
assert.throws(function() {
7272
node.prepend({});
73-
});
73+
}, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
7474
assert.throws(function() {
7575
node.prepend(function() {});
76-
});
76+
}, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
7777
};
7878

7979
exports["test .toString()"] = function(assert) {

0 commit comments

Comments
 (0)