aboutsummaryrefslogtreecommitdiffstats
path: root/settings/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-04-08 22:08:37 +0200
committerLukas Reschke <lukas@owncloud.com>2015-04-08 22:08:37 +0200
commit98698e05e86a85e3f9aa813c314c3ed6739fbb43 (patch)
treec62cfc8b4bfb7a2233ae0a16acd280c3f32ea65d /settings/tests
parenteb1cf58d11a6514261eb11abde37ed924cfa8a51 (diff)
downloadnextcloud-server-98698e05e86a85e3f9aa813c314c3ed6739fbb43.tar.gz
nextcloud-server-98698e05e86a85e3f9aa813c314c3ed6739fbb43.zip
Add JS unit test for sorting
Diffstat (limited to 'settings/tests')
-rw-r--r--settings/tests/js/appsSpec.js54
1 files changed, 54 insertions, 0 deletions
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');
+ });
+ });
+
});