autocomplete-test.js revision b3b2ec1d995b702710dfb721aa7b363101d9ab85
ArrayAssert = Y.ArrayAssert,
initializer: function () {
this._bindUIACBase();
this._syncUIACBase();
},
destructor: function () {
this._destructorACBase();
}
});
// -- Global Suite -------------------------------------------------------------
// -- Base Suite ---------------------------------------------------------------
// -- Base: Lifecycle ----------------------------------------------------------
name: 'Lifecycle',
_should: {
error: {
'Initializer should require an inputNode': 'No inputNode specified.'
}
},
setUp: function () {
},
tearDown: function () {
delete this.inputNode;
},
'Initializer should accept an inputNode': function () {
},
'Initializer should require an inputNode': function () {
// Should fail.
}
}));
// -- Base: Attributes ---------------------------------------------------------
name: 'Attributes',
setUp: function () {
},
tearDown: function () {
delete this.ac;
delete this.inputNode;
},
'Browser autocomplete should be off by default': function () {
},
'Browser autocomplete should be turned on when enabled': function () {
allowBrowserAutocomplete: true
});
},
'Browser autocomplete should be settable after init': function () {
},
'inputNode should be writable only on init': function () {
},
'requestTemplate should accept a custom template function': function () {
return 'query: ' + query;
};
},
'requestTemplate should generate a template function when set to a string': function () {
},
'requestTemplate function should replace {query} with the URI-encoded query': function () {
var rt;
},
// -- Setters and validators -----------------------------------------------
'_functionValidator() should accept a function or null': function () {
},
'_setSource() should accept a DataSource': function () {
},
'_setSource() should accept an array': function () {
},
'_setSource() should accept an object': function () {
},
'_setSource() should accept a URL string': function () {
},
'_setSource() should accept a YQL string': function () {
},
'_setSource() should accept a Y.JSONPRequest instance': function () {
}
}));
// -- Filters Suite ------------------------------------------------------------
// -- Filters: API -------------------------------------------------------------
name: 'API',
// -- charMatch() ----------------------------------------------------------
'charMatch() should match all characters in the query, in any order': function () {
['cab', 'taxi cab'],
);
},
'charMatch() should be case-insensitive': function () {
['Foo', 'foo'],
);
},
'charMatchCase() should be case-sensitive': function () {
['foo'],
);
},
'charMatchFold() should match accent-folded characters': function () {
['fóó', 'föö', 'foo'],
);
// Accent-folded matches are always case-insensitive.
['FÓÓ', 'FÖÖ', 'FOO'],
);
},
// -- phraseMatch() --------------------------------------------------------
'phraseMatch() should match the complete query as a phrase': function () {
['foo bar'],
);
['xxfoo barxx'],
);
['foo barxx'],
);
['xxfoo bar'],
);
},
'phraseMatch() should be case-insensitive': function () {
['Foo', 'foo'],
);
},
'phraseMatchCase() should be case-sensitive': function () {
['foo'],
);
},
'phraseMatchFold() should match accent-folded characters': function () {
['fóó', 'föö', 'foo'],
);
// Accent-folded matches are always case-insensitive.
['FÓÓ', 'FÖÖ', 'FOO'],
);
},
// -- startsWith() ---------------------------------------------------------
'startsWith() should match the complete query at the start of a result': function () {
['foo', 'foo bar'],
);
},
'startsWith() should be case-insensitive': function () {
['Foo', 'foo'],
);
},
'startsWithCase() should be case-sensitive': function () {
['foo'],
);
},
'startsWithFold() should match accent-folded characters': function () {
['fóó', 'föö', 'foo'],
);
// Accent-folded matches are always case-insensitive.
['FÓÓ', 'FÖÖ', 'FOO'],
);
},
// -- wordMatch() ----------------------------------------------------------
'wordMatch() should match results that contain all words in the query in any order': function () {
['foo bar baz'],
);
['foo', 'foo bar baz'],
);
},
'wordMatch() should be case-insensitive': function () {
['Foo', 'foo'],
);
},
'wordMatchCase() should be case-sensitive': function () {
['foo'],
);
},
'wordMatchFold() should match accent-folded characters': function () {
['fóó', 'föö', 'foo'],
);
// Accent-folded matches are always case-insensitive.
['FÓÓ', 'FÖÖ', 'FOO'],
);
}
}));
// -- Highlighters Suite -------------------------------------------------------
// -- Highlighters: API --------------------------------------------------------
name: 'API',
// -- charMatch() ----------------------------------------------------------
'charMatch() should highlight all characters in the query, in any order': function () {
['foo', '<b class="yui3-highlight">b</b><b class="yui3-highlight">a</b>r', '<b class="yui3-highlight">b</b><b class="yui3-highlight">a</b>z'],
);
},
'charMatch() should be case-insensitive': function () {
['<b class="yui3-highlight">F</b>oo', '<b class="yui3-highlight">f</b>oo'],
);
},
// -- charMatchCase() ------------------------------------------------------
'charMatchCase() should be case-sensitive': function () {
['Foo', '<b class="yui3-highlight">f</b>oo'],
);
},
// -- charMatchFold() ------------------------------------------------------
'charMatchFold() should highlight accent-folded characters': function () {
['f<b class="yui3-highlight">ó</b><b class="yui3-highlight">ó</b>', 'f<b class="yui3-highlight">o</b><b class="yui3-highlight">o</b>', 'bar'],
);
['f<b class="yui3-highlight">o</b><b class="yui3-highlight">o</b>', 'f<b class="yui3-highlight">o</b><b class="yui3-highlight">o</b>', 'bar'],
);
},
// -- phraseMatch() --------------------------------------------------------
'phraseMatch() should highlight the complete query as a phrase': function () {
['foo', 'bar', 'foo bar'],
);
['foo', 'bar', '<b class="yui3-highlight">foo bar</b>'],
);
['<b class="yui3-highlight">foo</b>', 'bar', '<b class="yui3-highlight">foo</b> bar'],
);
['foo', 'bar', 'xx<b class="yui3-highlight">foo bar</b>'],
);
},
'phraseMatch() should be case-insensitive': function () {
['<b class="yui3-highlight">Foo</b>', '<b class="yui3-highlight">foo</b>'],
);
},
// -- phraseMatchCase() ----------------------------------------------------
'phraseMatchCase() should be case-sensitive': function () {
['Foo', '<b class="yui3-highlight">foo</b>'],
);
},
// -- phraseMatchFold() ----------------------------------------------------
'phraseMatchFold() should match accent-folded characters': function () {
['<b class="yui3-highlight">fóó</b>bar', 'bar<b class="yui3-highlight">foo</b>', 'bar'],
);
['<b class="yui3-highlight">foo</b>bar', 'bar<b class="yui3-highlight">foo</b>', 'bar'],
);
},
// -- startsWith() ---------------------------------------------------------
'startsWith() should highlight the complete query at the start of a result': function () {
['xx foo', 'bar', 'xx foo bar'],
);
['<b class="yui3-highlight">foo</b>', 'bar foo', '<b class="yui3-highlight">foo</b> bar'],
);
},
'startsWith() should be case-insensitive': function () {
['<b class="yui3-highlight">Foo</b>', '<b class="yui3-highlight">foo</b>'],
);
},
// -- startsWithCase() -----------------------------------------------------
'startsWithCase() should be case-sensitive': function () {
['Foo', '<b class="yui3-highlight">foo</b>'],
);
},
// -- startsWithFold() -----------------------------------------------------
'startsWithFold() should match accent-folded characters': function () {
['<b class="yui3-highlight">fóó</b>', 'barfoo', 'bar'],
);
['<b class="yui3-highlight">foo</b>', 'barfoo', 'bar'],
);
},
// -- wordMatch() ----------------------------------------------------------
'wordMatch() should highlight complete words in the query': function () {
['foobar', 'barbaz'],
);
['<b class="yui3-highlight">foo</b>', '<b class="yui3-highlight">bar</b>', '<b class="yui3-highlight">foo</b> <b class="yui3-highlight">bar</b> <b class="yui3-highlight">baz</b>', 'foobar <b class="yui3-highlight">baz</b>'],
);
},
'wordMatch() should be case-insensitive': function () {
['<b class="yui3-highlight">Foo</b>', '<b class="yui3-highlight">foo</b>'],
);
},
// -- wordMatchCase() ------------------------------------------------------
'wordMatchCase() should be case-sensitive': function () {
['Foo', '<b class="yui3-highlight">foo</b>'],
);
},
'wordMatchFold() should match accent-folded characters': function () {
['<b class="yui3-highlight">fóó</b>', '<b class="yui3-highlight">foo</b>', 'barfoo'],
);
['<b class="yui3-highlight">foo</b>', '<b class="yui3-highlight">fóó</b>', 'barfoo'],
);
}
}));
}, '@VERSION@', {
requires: [
'autocomplete-base', 'autocomplete-filters',
'autocomplete-filters-accentfold', 'autocomplete-highlighters',
'autocomplete-highlighters-accentfold', 'datasource-local', 'node',
'jsonp', 'test', 'yql'
]
});