highlight-test.js revision 84df72e8dfc289d41c2b6efd382a2dfc8c2d867d
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 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',
);
},
// -- 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',
);
},
'allFold() should not choke when single chars are folded into multiple chars': function () {
'encyclo<b class="yui3-highlight">pædia</b> set',
);
'encyclo<b class="yui3-highlight">paedia</b> set',
);
'<b class="yui3-highlight">ae</b><b class="yui3-highlight">ae</b><b class="yui3-highlight">ae</b>bbb<b class="yui3-highlight">ae</b><b class="yui3-highlight">ae</b><b class="yui3-highlight">ae</b>',
);
},
// -- 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 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',
);
},
// -- 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',
);
},
'wordsFold() should not choke when single chars are folded into multiple chars': function () {
'<b class="yui3-highlight">Encyclopædia</b> <b class="yui3-highlight">Brittænicæ</b>',
);
'<b class="yui3-highlight">Encyclopaedia</b> <b class="yui3-highlight">Brittaenicae</b>',
);
}
}));