From 98698e05e86a85e3f9aa813c314c3ed6739fbb43 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 8 Apr 2015 22:08:37 +0200 Subject: [PATCH] Add JS unit test for sorting --- settings/tests/js/appsSpec.js | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/settings/tests/js/appsSpec.js b/settings/tests/js/appsSpec.js index 39329c19246..311fade2c66 100644 --- a/settings/tests/js/appsSpec.js +++ b/settings/tests/js/appsSpec.js @@ -98,4 +98,58 @@ describe('OC.Settings.Apps tests', function() { expect(results[0]).toEqual('somestuff'); }); }); + + describe('loading categories', function() { + var suite = this; + + beforeEach( function(){ + suite.server = sinon.fakeServer.create(); + }); + + afterEach( function(){ + suite.server.restore(); + }); + + function getResultsFromDom() { + var results = []; + $('#apps-list .section:not(.hidden)').each(function() { + results.push($(this).attr('data-id')); + }); + return results; + } + + it('sorts all applications using the level', function() { + Apps.loadCategory('TestId'); + + suite.server.requests[0].respond( + 200, + { + 'Content-Type': 'application/json' + }, + JSON.stringify({ + apps: [ + { + id: 'foo', + level: 0 + }, + { + id: 'alpha', + level: 300 + }, + { + id: 'delta', + level: 200 + } + ] + }) + ); + + var results = getResultsFromDom(); + expect(results.length).toEqual(3); + expect(results[0]).toEqual('alpha'); + expect(results[1]).toEqual('delta'); + expect(results[2]).toEqual('foo'); + }); + }); + }); -- 2.39.5