Bug 1452706 - Add the 'expected' arguments to throws/rejects for devtools/shared/sourcemap. r?yulia
MozReview-Commit-ID: AdOD0Txwdi7
--- a/devtools/shared/sourcemap/tests/unit/test_base64.js
+++ b/devtools/shared/sourcemap/tests/unit/test_base64.js
@@ -61,20 +61,20 @@ var SOURCE_MAP_TEST_MODULE =
* http://opensource.org/licenses/BSD-3-Clause
*/
var base64 = __webpack_require__(1);
exports['test out of range encoding'] = function (assert) {
assert.throws(function () {
base64.encode(-1);
- });
+ }, /Must be between 0 and 63/);
assert.throws(function () {
base64.encode(64);
- });
+ }, /Must be between 0 and 63/);
};
exports['test out of range decoding'] = function (assert) {
assert.equal(base64.decode('='.charCodeAt(0)), -1);
};
exports['test normal encoding and decoding'] = function (assert) {
for (var i = 0; i < 64; i++) {
--- a/devtools/shared/sourcemap/tests/unit/test_source_map_generator.js
+++ b/devtools/shared/sourcemap/tests/unit/test_source_map_generator.js
@@ -135,38 +135,38 @@ var SOURCE_MAP_TEST_MODULE =
var map = new SourceMapGenerator({
file: 'generated-foo.js',
sourceRoot: '.'
});
// Not enough info.
assert.throws(function () {
map.addMapping({});
- });
+ }, /"generated" is a required argument/);
// Original file position, but no source.
assert.throws(function () {
map.addMapping({
generated: { line: 1, column: 1 },
original: { line: 1, column: 1 }
});
- });
+ }, /Invalid mapping/);
};
exports['test adding mappings with skipValidation'] = function (assert) {
var map = new SourceMapGenerator({
file: 'generated-foo.js',
sourceRoot: '.',
skipValidation: true
});
// Not enough info, caught by `util.getArgs`
assert.throws(function () {
map.addMapping({});
- });
+ }, /"generated" is a required argument/);
// Original file position, but no source. Not checked.
assert.doesNotThrow(function () {
map.addMapping({
generated: { line: 1, column: 1 },
original: { line: 1, column: 1 }
});
});
@@ -391,17 +391,17 @@ var SOURCE_MAP_TEST_MODULE =
exports['test applySourceMap throws when file is missing'] = function (assert) {
var map = new SourceMapGenerator({
file: 'test.js'
});
var map2 = new SourceMapGenerator();
assert.throws(function() {
map.applySourceMap(new SourceMapConsumer(map2.toJSON()));
- });
+ }, /Error: SourceMapGenerator.prototype.applySourceMap requires either an explicit source file/);
};
exports['test the two additional parameters of applySourceMap'] = function (assert) {
// Assume the following directory structure:
//
// http://foo.org/
// bar.coffee
// app/
--- a/devtools/shared/sourcemap/tests/unit/test_source_node.js
+++ b/devtools/shared/sourcemap/tests/unit/test_source_node.js
@@ -85,20 +85,20 @@ var SOURCE_MAP_TEST_MODULE =
node.add(['function foo() {',
new SourceNode(null, null, null,
'return 10;'),
'}']);
// Adding other stuff doesn't.
assert.throws(function () {
node.add({});
- });
+ }, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
assert.throws(function () {
node.add(function () {});
- });
+ }, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
};
exports['test .prepend()'] = function (assert) {
var node = new SourceNode(null, null, null);
// Prepending a string works.
node.prepend('function noop() {}');
assert.equal(node.children[0], 'function noop() {}');
@@ -120,20 +120,20 @@ var SOURCE_MAP_TEST_MODULE =
assert.equal(node.children[2], '}');
assert.equal(node.children[3], '');
assert.equal(node.children[4], 'function noop() {}');
assert.equal(node.children.length, 5);
// Prepending other stuff doesn't.
assert.throws(function () {
node.prepend({});
- });
+ }, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
assert.throws(function () {
node.prepend(function () {});
- });
+ }, /TypeError: Expected a SourceNode, string, or an array of SourceNodes and strings/);
};
exports['test .toString()'] = function (assert) {
assert.equal((new SourceNode(null, null, null,
['function foo() {',
new SourceNode(null, null, null, 'return 10;'),
'}'])).toString(),
'function foo() {return 10;}');