Skip to content

Commit

Permalink
fix(privateMocks): allow replacing $prop with strings with special …
Browse files Browse the repository at this point in the history
…RegExp semantics

`baseThey` used to construct the testcase description by replacing `$prop` using a RegExp.
If the replacement string contained `$&` (which has a special meaning with RegExps), the resulting
string was not as expected.x
  • Loading branch information
gkalpak committed Dec 15, 2015
1 parent 1b25f80 commit 031303d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/helpers/privateMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function baseThey(msg, vals, spec, itFn) {
var valsIsArray = angular.isArray(vals);

angular.forEach(vals, function(val, key) {
var m = msg.replace(/\$prop/g, angular.toJson(valsIsArray ? val : key));
var m = msg.split('$prop').join(angular.toJson(valsIsArray ? val : key));
itFn(m, function() {
/* jshint -W040 : ignore possible strict violation due to use of this */
spec.call(this, val);
Expand Down

2 comments on commit 031303d

@Narretz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private code should not get fix(..., because it will then go into the changelog. Just refactor / chore should be fine. Or test? Since it concerns tests.

@gkalpak
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll fix the commit message.

Please sign in to comment.