From ada0a65147bc0141f3eb36bca578f5bfefe6e075 Mon Sep 17 00:00:00 2001 From: splitt3r Date: Thu, 4 Jan 2018 14:01:20 +0100 Subject: [PATCH] Added basic unit tests --- settings/tests/js/apps/appSettingsSpec.js | 63 +++++++++++++++++++++++ tests/karma.config.js | 6 ++- 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 settings/tests/js/apps/appSettingsSpec.js diff --git a/settings/tests/js/apps/appSettingsSpec.js b/settings/tests/js/apps/appSettingsSpec.js new file mode 100644 index 000000000000..38b4f8234798 --- /dev/null +++ b/settings/tests/js/apps/appSettingsSpec.js @@ -0,0 +1,63 @@ +/** +* ownCloud +* +* @author Kai Schröer +* @copyright 2018 Kai Schröer +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see . +* +*/ + +describe('App Settings tests', function() { + var apps = [ + { + "author": "Author 1, Author 2", + "types": [ + "logging", + "dav" + ] + }, + { + "author": [ + "Author 1", + "Author 2", + { + "@attributes": { + "email": "author3@owncloud.org" + }, + "@value": "Author 3" + } + ], + "types": [ + "filesystem" + ] + } + ]; + + it('should parse the author info', function() { + var author = OC.Settings.Apps._parseAppAuthor(apps[0].author); + expect(author).toEqual('Author 1, Author 2'); + + author = OC.Settings.Apps._parseAppAuthor(apps[1].author); + expect(author).toEqual('Author 1, Author 2, Author 3'); + }); + + it('should check the app type', function() { + var isFilesystem = OC.Settings.Apps.isType(apps[0], 'filesystem'); + expect(isFilesystem).toEqual(false); + + isFilesystem = OC.Settings.Apps.isType(apps[1], 'filesystem'); + expect(isFilesystem).toEqual(true); + }); +}); diff --git a/tests/karma.config.js b/tests/karma.config.js index 2f99bee5033f..370f9e8aa1e4 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -110,10 +110,12 @@ module.exports = function(config) { { name: 'settings', srcFiles: [ - 'settings/js/users/deleteHandler.js' + 'settings/js/users/deleteHandler.js', + 'settings/js/admin-apps.js' ], testFiles: [ - 'settings/tests/js/users/deleteHandlerSpec.js' + 'settings/tests/js/users/deleteHandlerSpec.js', + 'settings/tests/js/apps/appSettingsSpec.js' ] } ];