Skip to content

Commit

Permalink
style(*): fix no-useless-escape eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Nov 29, 2016
1 parent 1dedcdf commit 736b6c7
Show file tree
Hide file tree
Showing 36 changed files with 59 additions and 91 deletions.
2 changes: 1 addition & 1 deletion docs/app/src/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ angular.module('DocsController', ['currentVersionData'])
$scope.loading = 0;


var INDEX_PATH = /^(\/|\/index[^\.]*.html)$/;
var INDEX_PATH = /^(\/|\/index[^.]*.html)$/;
if (!$location.path() || INDEX_PATH.test($location.path())) {
$location.path('/api').replace();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/app/src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
angular.module('errors', ['ngSanitize'])

.filter('errorLink', ['$sanitize', function($sanitize) {
var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s\.;,\(\)\{\}<>]/g,
var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>]/g,
MAILTO_REGEXP = /^mailto:/,
STACK_TRACE_REGEXP = /:\d+:\d+$/;

Expand Down
2 changes: 1 addition & 1 deletion docs/app/src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ angular.module('search', [])

.controller('Error404SearchCtrl', ['$scope', '$location', 'docsSearch',
function($scope, $location, docsSearch) {
docsSearch($location.path().split(/[\/\.:]/).pop()).then(function(results) {
docsSearch($location.path().split(/[/.:]/).pop()).then(function(results) {
$scope.results = {};
angular.forEach(results, function(result) {
var area = $scope.results[result.area] || [];
Expand Down
4 changes: 2 additions & 2 deletions docs/config/processors/keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
var areasToSearch;

// Keywords start with "ng:" or one of $, _ or a letter
var KEYWORD_REGEX = /^((ng:|[\$_a-z])[\w\-_]+)/;
var KEYWORD_REGEX = /^((ng:|[$_a-z])[\w\-_]+)/;

// Load up the keywords to ignore, if specified in the config
if (this.ignoreWordsFile) {
Expand Down Expand Up @@ -67,7 +67,7 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {

function extractWords(text, words, keywordMap) {

var tokens = text.toLowerCase().split(/[\.\s,`'"#]+/mg);
var tokens = text.toLowerCase().split(/[.\s,`'"#]+/mg);
_.forEach(tokens, function(token) {
var match = token.match(KEYWORD_REGEX);
if (match) {
Expand Down
2 changes: 1 addition & 1 deletion docs/content/guide/forms.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ In the following example we create two directives:
<file name="script.js">
var app = angular.module('form-example1', []);

var INTEGER_REGEXP = /^\-?\d+$/;
var INTEGER_REGEXP = /^-?\d+$/;
app.directive('integer', function() {
return {
require: 'ngModel',
Expand Down
32 changes: 0 additions & 32 deletions init-repo.sh

This file was deleted.

2 changes: 1 addition & 1 deletion lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module.exports = {
var classPathSep = (process.platform === 'win32') ? ';' : ':';
var minFile = file.replace(/\.js$/, '.min.js');
var mapFile = minFile + '.map';
var mapFileName = mapFile.match(/[^\/]+$/)[0];
var mapFileName = mapFile.match(/[^/]+$/)[0];
var errorFileName = file.replace(/\.js$/, '-errors.json');
var versionNumber = grunt.config('NG_VERSION').full;
var compilationLevel = (file === 'build/angular-message-format.js') ?
Expand Down
2 changes: 1 addition & 1 deletion lib/versions/version-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var getPackage = function() {
* @return {Object} An object containing the github owner and repository name
*/
var getGitRepoInfo = function() {
var GITURL_REGEX = /^https:\/\/github.com\/([^\/]+)\/(.+).git$/;
var GITURL_REGEX = /^https:\/\/github.com\/([^/]+)\/(.+).git$/;
var match = GITURL_REGEX.exec(currentPackage.repository.url);
var git = {
owner: match[1],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ then(allInSeries(function(branch) {
line = line.split(' ');
var sha = line.shift();
var msg = line.join(' ');
return sha + ((/fix\([^\)]+\):/i.test(msg)) ? ' * ' : ' ') + msg;
return sha + ((/fix\([^)]+\):/i.test(msg)) ? ' * ' : ' ') + msg;
});
branch.log = log.map(function(line) {
return line.substr(41);
Expand Down
2 changes: 1 addition & 1 deletion validate-commit-msg.js → scripts/validate-commit-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var util = require('util');


var MAX_LENGTH = 100;
var PATTERN = /^(?:fixup!\s*)?(\w*)(\(([\w\$\.\*/-]*)\))?: (.*)$/;
var PATTERN = /^(?:fixup!\s*)?(\w*)(\(([\w$.*/-]*)\))?: (.*)$/;
var IGNORED = /^WIP:/;
var TYPES = {
feat: true,
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ function isPromiseLike(obj) {
}


var TYPED_ARRAY_REGEXP = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
var TYPED_ARRAY_REGEXP = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array]$/;
function isTypedArray(value) {
return value && isNumber(value.length) && TYPED_ARRAY_REGEXP.test(toString.call(value));
}
Expand All @@ -729,7 +729,7 @@ var trim = function(value) {
// Prereq: s is a string.
var escapeForRegexp = function(s) {
return s
.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1')
.replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, '\\$1')
// eslint-disable-next-line no-control-regex
.replace(/\x08/g, '\\x08');
};
Expand Down Expand Up @@ -973,7 +973,7 @@ function copy(source, destination) {
return new source.constructor(source.valueOf());

case '[object RegExp]':
var re = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]);
var re = new RegExp(source.source, source.toString().match(/[^/]*$/)[0]);
re.lastIndex = source.lastIndex;
return re;

Expand Down Expand Up @@ -1350,7 +1350,7 @@ function startingTag(element) {
return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) :
elemHtml.
match(/^(<[^>]+>)/)[1].
replace(/^<([\w\-]+)/, function(match, nodeName) {return '<' + lowercase(nodeName);});
replace(/^<([\w-]+)/, function(match, nodeName) {return '<' + lowercase(nodeName);});
} catch (e) {
return lowercase(elemHtml);
}
Expand Down
4 changes: 2 additions & 2 deletions src/auto/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
* Implicit module which gets automatically added to each {@link auto.$injector $injector}.
*/

var ARROW_ARG = /^([^\(]+?)=>/;
var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m;
var ARROW_ARG = /^([^(]+?)=>/;
var FN_ARGS = /^[^(]*\(\s*([^)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
Expand Down
2 changes: 1 addition & 1 deletion src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function Browser(window, document, $log, $sniffer) {
*/
self.baseHref = function() {
var href = baseElement.attr('href');
return href ? href.replace(/^(https?:)?\/\/[^\/]*/, '') : '';
return href ? href.replace(/^(https?:)?\/\/[^/]*/, '') : '';
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,8 @@ $CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider'];
function $CompileProvider($provide, $$sanitizeUriProvider) {
var hasDirectives = {},
Suffix = 'Directive',
COMMENT_DIRECTIVE_REGEXP = /^\s*directive:\s*([\w\-]+)\s+(.*)$/,
CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?::([^;]+))?;?)/,
COMMENT_DIRECTIVE_REGEXP = /^\s*directive:\s*([\w-]+)\s+(.*)$/,
CLASS_DIRECTIVE_REGEXP = /(([\w-]+)(?::([^;]+))?;?)/,
ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'),
REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/;

Expand Down
8 changes: 4 additions & 4 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ var ISO_DATE_REGEXP = /^\d{4,}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+(?:[+-
// 7. Path
// 8. Query
// 9. Fragment
// 1111111111111111 222 333333 44444 555555555555555555555555 666 77777777 8888888 999
var URL_REGEXP = /^[a-z][a-z\d.+-]*:\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+\])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i;
// 1111111111111111 222 333333 44444 55555555555555555555555 666 77777777 8888888 999
var URL_REGEXP = /^[a-z][a-z\d.+-]*:\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i;
// eslint-disable-next-line max-len
var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/;
var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
var NUMBER_REGEXP = /^\s*(-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/;
var DATE_REGEXP = /^(\d{4,})-(\d{2})-(\d{2})$/;
var DATETIMELOCAL_REGEXP = /^(\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/;
var WEEK_REGEXP = /^(\d{4,})-W(\d\d)$/;
Expand Down
4 changes: 2 additions & 2 deletions src/ng/directive/ngOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ var ngOptionsMinErr = minErr('ngOptions');
*/

/* eslint-disable max-len */
// //00001111111111000000000002222222222000000000000000000000333333333300000000000000000000000004444444444400000000000005555555555555550000000006666666666666660000000777777777777777000000000000000888888888800000000000000000009999999999
var NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?(?:\s+disable\s+when\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/;
// //00001111111111000000000002222222222000000000000000000000333333333300000000000000000000000004444444444400000000000005555555555555000000000666666666666600000007777777777777000000000000000888888888800000000000000000009999999999
var NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?(?:\s+disable\s+when\s+([\s\S]+?))?\s+for\s+(?:([$\w][$\w]*)|(?:\(\s*([$\w][$\w]*)\s*,\s*([$\w][$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/;
// 1: value expression (valueFn)
// 2: label expression (displayFn)
// 3: group by expression (groupByFn)
Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/ngRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ var ngRepeatDirective = ['$parse', '$animate', '$compile', function($parse, $ani
var aliasAs = match[3];
var trackByExp = match[4];

match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);
match = lhs.match(/^(?:(\s*[$\w]+)|\(\s*([$\w]+)\s*,\s*([$\w]+)\s*\))$/);

if (!match) {
throw ngRepeatMinErr('iidexp', '\'_item_\' in \'_item_ in _collection_\' should be an identifier or \'(_key_, _value_)\' expression, but got \'{0}\'.',
Expand Down
4 changes: 2 additions & 2 deletions src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ var DATE_FORMATS = {
};

var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,
NUMBER_STRING = /^\-?\d+$/;
NUMBER_STRING = /^-?\d+$/;

/**
* @ngdoc filter
Expand Down Expand Up @@ -563,7 +563,7 @@ var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+
expect(element(by.binding("1288323623006 | date:'medium'")).getText()).
toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/);
expect(element(by.binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).getText()).
toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/);
toMatch(/2010-10-2\d \d{2}:\d{2}:\d{2} (-|\+)?\d{4}/);
expect(element(by.binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).getText()).
toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/);
expect(element(by.binding("'1288323623006' | date:\"MM/dd/yyyy 'at' h:mma\"")).getText()).
Expand Down
2 changes: 1 addition & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var JSON_ENDS = {
'[': /]$/,
'{': /}$/
};
var JSON_PROTECTION_PREFIX = /^\)\]\}',?\n/;
var JSON_PROTECTION_PREFIX = /^\)]\}',?\n/;
var $httpMinErr = minErr('$http');

function serializeValue(v) {
Expand Down
2 changes: 1 addition & 1 deletion src/ng/location.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/,
var PATH_MATCH = /^([^?#]*)(\?([^#]*))?(#(.*))?$/,
DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp': 21};
var $locationMinErr = minErr('$location');

Expand Down
4 changes: 2 additions & 2 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {

url = url
.replace(/([().])/g, '\\$1')
.replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) {
.replace(/(\/)?:(\w+)([?*])?/g, function(_, slash, key, option) {
var optional = option === '?' ? option : null;
var star = option === '*' ? option : null;
keys.push({ name: key, optional: !!optional });
Expand All @@ -1602,7 +1602,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
+ ')'
+ (optional || '');
})
.replace(/([\/$\*])/g, '\\$1');
.replace(/([/$*])/g, '\\$1');

ret.regexp = new RegExp('^' + url, 'i');
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/ngResource/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ function shallowClearAndCopy(src, dst) {
*/
angular.module('ngResource', ['ng']).
provider('$resource', function ResourceProvider() {
var PROTOCOL_AND_DOMAIN_REGEX = /^https?:\/\/[^\/]*/;
var PROTOCOL_AND_DOMAIN_REGEX = /^https?:\/\/[^/]*/;

var provider = this;

Expand Down
4 changes: 2 additions & 2 deletions src/ngRoute/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function $RouteProvider() {

path = path
.replace(/([().])/g, '\\$1')
.replace(/(\/)?:(\w+)(\*\?|[\?\*])?/g, function(_, slash, key, option) {
.replace(/(\/)?:(\w+)(\*\?|[?*])?/g, function(_, slash, key, option) {
var optional = (option === '?' || option === '*?') ? '?' : null;
var star = (option === '*' || option === '*?') ? '*' : null;
keys.push({ name: key, optional: !!optional });
Expand All @@ -275,7 +275,7 @@ function $RouteProvider() {
+ ')'
+ (optional || '');
})
.replace(/([\/$\*])/g, '\\$1');
.replace(/([/$*])/g, '\\$1');

ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : '');
return ret;
Expand Down
4 changes: 2 additions & 2 deletions test/auto/injectorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ describe('injector', function() {
expect(function() {
createInjector(['IDontExist'], {});
}).toThrowMinErr('$injector', 'modulerr',
/\[\$injector:nomod\] Module 'IDontExist' is not available! You either misspelled the module name or forgot to load it/);
/\[\$injector:nomod] Module 'IDontExist' is not available! You either misspelled the module name or forgot to load it/);
});


Expand Down Expand Up @@ -782,7 +782,7 @@ describe('injector', function() {
createInjector([
{}
], {});
}).toThrowMinErr('$injector', 'modulerr', /Failed to instantiate module \{\} due to:\n.*\[ng:areq\] Argument 'module' is not a function, got Object/);
}).toThrowMinErr('$injector', 'modulerr', /Failed to instantiate module \{\} due to:\n.*\[ng:areq] Argument 'module' is not a function, got Object/);
});


Expand Down
2 changes: 1 addition & 1 deletion test/helpers/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ beforeEach(function() {
// This function escapes all special regex characters.
// We use it to create matching regex from arbitrary strings.
// http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
}

function test(exception) {
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/testabilityPatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function sortedHtml(element, showNgClass) {
}

var attr = attributes[i];
if (attr.name.match(/^ng[:\-]/) ||
if (attr.name.match(/^ng[:-]/) ||
(attr.value || attr.value === '') &&
attr.value !== 'null' &&
attr.value !== 'auto' &&
Expand Down Expand Up @@ -241,7 +241,7 @@ function sortedHtml(element, showNgClass) {
var tmp = style;
style = [];
forEach(tmp, function(value) {
if (!value.match(/^max[^\-]/)) {
if (!value.match(/^max[^-]/)) {
style.push(value);
}
});
Expand Down
12 changes: 6 additions & 6 deletions test/minErrSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('minErr', function() {

it('should interpolate string arguments without quotes', function() {
var myError = testError('1', 'This {0} is "{1}"', 'foo', 'bar');
expect(myError.message).toMatch(/^\[test:1\] This foo is "bar"/);
expect(myError.message).toMatch(/^\[test:1] This foo is "bar"/);
});

it('should interpolate non-string arguments', function() {
Expand All @@ -57,7 +57,7 @@ describe('minErr', function() {
var myError = testError('26', 'false: {0}; zero: {1}; null: {2}; undefined: {3}; emptyStr: {4}',
false, 0, null, undefined, '');
expect(myError.message).
toMatch(/^\[test:26\] false: false; zero: 0; null: null; undefined: undefined; emptyStr: /);
toMatch(/^\[test:26] false: false; zero: 0; null: null; undefined: undefined; emptyStr: /);
});

it('should handle arguments that are objects with cyclic references', function() {
Expand All @@ -74,20 +74,20 @@ describe('minErr', function() {
var foo = 'Fooooo',
myError = testError('26', 'This {0} is {1} on {2}', foo);

expect(myError.message).toMatch(/^\[test:26\] This Fooooo is \{1\} on \{2\}/);
expect(myError.message).toMatch(/^\[test:26] This Fooooo is \{1\} on \{2\}/);
});


it('should pass through the message if no interpolation is needed', function() {
var myError = testError('26', 'Something horrible happened!');
expect(myError.message).toMatch(/^\[test:26\] Something horrible happened!/);
expect(myError.message).toMatch(/^\[test:26] Something horrible happened!/);
});

it('should include a namespace in the message only if it is namespaced', function() {
var myError = emptyTestError('26', 'This is a {0}', 'Foo');
var myNamespacedError = testError('26', 'That is a {0}', 'Bar');
expect(myError.message).toMatch(/^\[26\] This is a Foo/);
expect(myNamespacedError.message).toMatch(/^\[test:26\] That is a Bar/);
expect(myError.message).toMatch(/^\[26] This is a Foo/);
expect(myNamespacedError.message).toMatch(/^\[test:26] That is a Bar/);
});


Expand Down
Loading

0 comments on commit 736b6c7

Please sign in to comment.