-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1698 from benvinegar/fix-1687-2
Escape test/suite title for re in html reporter
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<html> | ||
<head> | ||
<title>Mocha</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="../../mocha.css" /> | ||
<script src="../../mocha.js"></script> | ||
<script>mocha.setup('bdd')</script> | ||
<script> | ||
function assert(expr, msg) { | ||
if (!expr) throw new Error(msg || 'failed'); | ||
} | ||
</script> | ||
<script src="ui.js"></script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script> | ||
(function(window) { | ||
var location = window.location; | ||
mocha.checkLeaks(); | ||
var runner = mocha.run(); | ||
var count = 0; | ||
setTimeout(run, 1000); | ||
|
||
function run() { | ||
var regex = [ | ||
'', // All | ||
'%5C%24%5C.jQuery', // $.jQuery | ||
'%5C%24%5C.jQuery%20%5C.on%5C(%5C)', // $.jQuery .on() | ||
] | ||
, qs = location.search.replace('?grep=', '') | ||
, re = ~qs.indexOf('%') ? qs : decodeURIComponent(qs) | ||
, grep = regex[regex.indexOf(re) + 1] | ||
, anchors = document.getElementsByTagName('a'); | ||
|
||
// Locate first 'a' element w/ matching grep param; click it | ||
for (var i = 0; i < anchors.length; i++) { | ||
if (anchors[i].href && anchors[i].href.indexOf(grep) > -1) | ||
return void anchors[i].click(); | ||
} | ||
} | ||
})(window); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// test titles containing regex-conflicting characters | ||
|
||
// leading $ | ||
describe('$.jQuery', function() { | ||
// parens | ||
describe('.on()', function () { | ||
it('should set an event', function() { | ||
assert(true); | ||
}); | ||
}); | ||
|
||
describe('.off()', function () { | ||
it('should remove an event', function () { | ||
|
||
}); | ||
}); | ||
}); | ||
|
||
// another generic describe block to verify it is absent | ||
// when greeping on $.jQuery | ||
describe('@Array', function() { | ||
it('.pop()', function() { | ||
assert(true); | ||
}); | ||
it('.push()', function() { | ||
assert(true); | ||
}); | ||
it('.length', function() { | ||
assert(true); | ||
}); | ||
}); |