diff options
Diffstat (limited to 'settings/tests/js/appsSpec.js')
-rw-r--r-- | settings/tests/js/appsSpec.js | 70 |
1 files changed, 62 insertions, 8 deletions
diff --git a/settings/tests/js/appsSpec.js b/settings/tests/js/appsSpec.js index 907d441ff4d..d2ca1fb5c8b 100644 --- a/settings/tests/js/appsSpec.js +++ b/settings/tests/js/appsSpec.js @@ -24,6 +24,7 @@ describe('OC.Settings.Apps tests', function() { beforeEach(function() { var $el = $('<div id="apps-list"></div>' + + '<div id="apps-list-empty" class="hidden"></div>' + '<div id="app-template">' + // dummy template for testing '<div id="app-{{id}}" data-id="{{id}}" class="section">{{name}}</div>' + @@ -59,22 +60,33 @@ describe('OC.Settings.Apps tests', function() { beforeEach(function() { loadApps([ - {id: 'appone', name: 'App One', description: 'The first app'}, - {id: 'apptwo', name: 'App Two', description: 'The second app'}, - {id: 'appthree', name: 'App Three', description: 'Third app'}, - {id: 'somestuff', name: 'Some Stuff', description: 'whatever'} + {id: 'appone', name: 'App One', description: 'The first app', author: 'author1', level: 200}, + {id: 'apptwo', name: 'App Two', description: 'The second app', author: 'author2', level: 100}, + {id: 'appthree', name: 'App Three', description: 'Third app', author: 'author3', level: 0}, + {id: 'somestuff', name: 'Some Stuff', description: 'whatever', author: 'author4', level: 0} ]); }); - it('does not filter when no query passed', function() { - Apps.filter(''); - expect(getResultsFromDom().length).toEqual(4); - }); it('returns no results when query does not match anything', function() { + expect(getResultsFromDom().length).toEqual(4); + expect($('#apps-list:not(.hidden)').length).toEqual(1); + expect($('#apps-list-empty:not(.hidden)').length).toEqual(0); + Apps.filter('absurdity'); expect(getResultsFromDom().length).toEqual(0); + expect($('#apps-list:not(.hidden)').length).toEqual(0); + expect($('#apps-list-empty:not(.hidden)').length).toEqual(1); + + Apps.filter(''); + expect(getResultsFromDom().length).toEqual(4); + expect($('#apps-list:not(.hidden)').length).toEqual(1); + expect($('#apps-list-empty:not(.hidden)').length).toEqual(0); + expect(getResultsFromDom().length).toEqual(4); }); it('returns relevant results when query matches name', function() { + expect($('#apps-list:not(.hidden)').length).toEqual(1); + expect($('#apps-list-empty:not(.hidden)').length).toEqual(0); + var results; Apps.filter('app'); results = getResultsFromDom(); @@ -82,6 +94,9 @@ describe('OC.Settings.Apps tests', function() { expect(results[0]).toEqual('appone'); expect(results[1]).toEqual('apptwo'); expect(results[2]).toEqual('appthree'); + + expect($('#apps-list:not(.hidden)').length).toEqual(1); + expect($('#apps-list-empty:not(.hidden)').length).toEqual(0); }); it('returns relevant result when query matches name', function() { var results; @@ -97,6 +112,45 @@ describe('OC.Settings.Apps tests', function() { expect(results.length).toEqual(1); expect(results[0]).toEqual('somestuff'); }); + it('returns relevant results when query matches author name', function() { + var results; + Apps.filter('author'); + results = getResultsFromDom(); + expect(results.length).toEqual(4); + expect(results[0]).toEqual('appone'); + expect(results[1]).toEqual('apptwo'); + expect(results[2]).toEqual('appthree'); + expect(results[3]).toEqual('somestuff'); + }); + it('returns relevant result when query matches author name', function() { + var results; + Apps.filter('thor3'); + results = getResultsFromDom(); + expect(results.length).toEqual(1); + expect(results[0]).toEqual('appthree'); + }); + it('returns relevant result when query matches level name', function() { + var results; + Apps.filter('Offic'); + results = getResultsFromDom(); + expect(results.length).toEqual(1); + expect(results[0]).toEqual('appone'); + }); + it('returns relevant result when query matches level name', function() { + var results; + Apps.filter('Appro'); + results = getResultsFromDom(); + expect(results.length).toEqual(1); + expect(results[0]).toEqual('apptwo'); + }); + it('returns relevant result when query matches level name', function() { + var results; + Apps.filter('Exper'); + results = getResultsFromDom(); + expect(results.length).toEqual(2); + expect(results[0]).toEqual('appthree'); + expect(results[1]).toEqual('somestuff'); + }); }); describe('loading categories', function() { |