+ testCases = [
+ {
+ query: 'group',
+ expectedMatches: {
+ group1: [ 'group1filter1', 'group1filter2' ],
+ group2: [ 'group2filter1' ]
+ },
+ reason: 'Finds filters starting with the query string'
+ },
+ {
+ query: 'filter 2 in group',
+ expectedMatches: {
+ group1: [ 'group1filter2' ],
+ group2: [ 'group2filter2' ]
+ },
+ reason: 'Finds filters containing the query string in their description'
+ },
+ {
+ query: 'title',
+ expectedMatches: {
+ group1: [ 'group1filter1', 'group1filter2' ],
+ group2: [ 'group2filter1', 'group2filter2' ]
+ },
+ reason: 'Finds filters containing the query string in their group title'
+ }
+ ],
+ model = new mw.rcfilters.dm.FiltersViewModel(),
+ extractNames = function ( matches ) {
+ var result = {};
+ Object.keys( matches ).forEach( function ( groupName ) {
+ result[ groupName ] = matches[ groupName ].map( function ( item ) {
+ return item.getName();
+ } );
+ } );
+ return result;
+ };