highlight-test.js revision 6e0d529cdcb8cd6be1aa06bf42252367110b2e9f
name: 'API',
// -- all() ----------------------------------------------------------------
'all() should highlight all occurrences of needles in haystack': function () {
// Array of needles.
'f<b class="yui3-highlight">oo</b> <b class="yui3-highlight">ba</b>r <b class="yui3-highlight">ba</b>z',
);
// Single string as needle.
'f<b class="yui3-highlight">oo</b> bar baz',
);
},
'all() should escape HTML characters': function () {
'<f<b class="yui3-highlight">oo</b>> & <<b class="yui3-highlight">ba</b>r>',
);
},
'all() should not highlight matches inside HTML entities': function () {
'&',
);
'/<b class="yui3-highlight">m</b>&<b class="yui3-highlight">m</b>/',
);
},
'all() should highlight complete HTML entities when part of a match': function () {
'<b class="yui3-highlight">&</b>',
);
'foo <b class="yui3-highlight">&</b> bar',
);
},
'all() should be case-insensitive by default': function () {
'f<b class="yui3-highlight">oo</b> <b class="yui3-highlight">BA</b>R <b class="yui3-highlight">ba</b>z',
);
},
'all() should support a caseSensitive option': function () {
'f<b class="yui3-highlight">oo</b> BAR <b class="yui3-highlight">ba</b>z',
);
},
'all() should support a startsWith option': function () {
'<b class="yui3-highlight">fo</b>o bar baz',
);
},
'all() should support caseSensitive and startsWith together': function () {
'FOO bar baz',
);
'<b class="yui3-highlight">FO</b>O bar baz',
);
},
// bug #2529945: http://yuilibrary.com/projects/yui3/ticket/2529945
'all() should not attempt to highlight empty needles': function () {
},
// -- allCase() ------------------------------------------------------------
'allCase() should be a shortcut for case-sensitive all()': function () {
'f<b class="yui3-highlight">oo</b> BAR <b class="yui3-highlight">ba</b>z',
);
},
// -- allFold() ------------------------------------------------------------
'allFold() should be an accent-folding variant of all()': function () {
'föo <b class="yui3-highlight">bár</b> baz',
);
'foo <b class="yui3-highlight">bar</b> baz',
);
'<foo> <b class="yui3-highlight">bar</b>',
);
'<b class="yui3-highlight">ds</b>w',
);
},
// bug #2529945: http://yuilibrary.com/projects/yui3/ticket/2529945
'allFold() should not attempt to highlight empty needles': function () {
},
// -- start() --------------------------------------------------------------
'start() should be a shortcut for all() with startsWith option': function () {
'<b class="yui3-highlight">fo</b>o bar baz',
);
},
// -- startCase() ----------------------------------------------------------
'startCase() should be a shortcut for caseSensitive + startsWith all()': function () {
'FOO bar baz',
);
'<b class="yui3-highlight">FO</b>O bar baz',
);
},
// -- startFold() ----------------------------------------------------------
'startFold() should be an accent-folding variant of start()': function () {
'föo bár baz',
);
'<b class="yui3-highlight">föo</b> bár baz',
);
'<b class="yui3-highlight">foo</b> bar baz',
);
},
// -- words() --------------------------------------------------------------
'words() should highlight complete words': function () {
// Array of words.
'foo <b class="yui3-highlight">bar</b> baz',
);
// String with single word.
'foo <b class="yui3-highlight">bar</b> baz',
);
// String with multiple words.
'<b class="yui3-highlight">foo</b> <b class="yui3-highlight">bar</b> baz',
);
// Repeated word.
'foo <b class="yui3-highlight">bar</b> baz <b class="yui3-highlight">bar</b>',
);
},
'words() should escape HTML characters': function () {
'<foo> & <<b class="yui3-highlight">bar</b>>',
);
},
'words() should not highlight matches inside HTML entities': function () {
'&',
);
'/<b class="yui3-highlight">m</b>&<b class="yui3-highlight">m</b>/',
);
},
'words() should be case-insensitive by default': function () {
'foo <b class="yui3-highlight">BAR</b> baz',
);
},
'words() should support a caseSensitive option': function () {
'foo BAR baz',
);
'foo <b class="yui3-highlight">BAR</b> baz',
);
},
// bug #2529945: http://yuilibrary.com/projects/yui3/ticket/2529945
'words() should not attempt to highlight empty needles': function () {
},
// -- wordsCase() ----------------------------------------------------------
'wordsCase() should be a shortcut for case-sensitive words()': function () {
'foo BAR baz',
);
'foo <b class="yui3-highlight">BAR</b> baz',
);
},
// -- wordsFold() ----------------------------------------------------------
'wordsFold() should be an accent-folding variant of words()': function () {
'föo bár baz',
);
'<b class="yui3-highlight">föo</b> <b class="yui3-highlight">bár</b> baz',
);
'<b class="yui3-highlight">föo</b> <b class="yui3-highlight">bár</b> baz',
);
'<b class="yui3-highlight">foo</b> <b class="yui3-highlight">bar</b> baz',
);
'<foo> <b class="yui3-highlight">bar</b>',
);
'<b class="yui3-highlight">O'Neal</b>',
);
},
// bug #2529945: http://yuilibrary.com/projects/yui3/ticket/2529945
'wordsFold() should not attempt to highlight empty needles': function () {
}
}));