Bug 1452706 - Add the 'expected' arguments to throws/rejects for devtools/shared/sourcemap. r?yulia draft
authorMark Banner <standard8@mozilla.com>
Tue, 03 Jul 2018 20:16:20 +0100
changeset 814484 535598b33b49bb5fef37fb072d93fcd2f23e7b0a
parent 814369 90be04d99fc7941cb9b7186bf5f95e184a4e989a
child 814485 59e979897e9cc2aa262a9112aac7debf91596fac
push id115229
push userbmo:standard8@mozilla.com
push dateThu, 05 Jul 2018 13:40:07 +0000
reviewersyulia
bugs1452706
milestone63.0a1
Bug 1452706 - Add the 'expected' arguments to throws/rejects for devtools/shared/sourcemap. r?yulia MozReview-Commit-ID: AdOD0Txwdi7
devtools/shared/sourcemap/tests/unit/test_base64.js
devtools/shared/sourcemap/tests/unit/test_source_map_generator.js
devtools/shared/sourcemap/tests/unit/test_source_node.js
--- 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;}');