diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2016-01-29 11:47:23 +0000 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2016-01-29 11:47:23 +0000 |
commit | 241ed17dc0a8d119c3fdf09a08c6aee5177dfa7c (patch) | |
tree | 5fe20faec02709a3900f5aa46c3dc8d01a39ec99 /apps | |
parent | 405e2d9b50eb40e28b0cd1f805042aae9d6512e8 (diff) | |
download | nextcloud-server-241ed17dc0a8d119c3fdf09a08c6aee5177dfa7c.tar.gz nextcloud-server-241ed17dc0a8d119c3fdf09a08c6aee5177dfa7c.zip |
Add storage validation JS unit tests
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/tests/js/settingsSpec.js | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js index b6372649fb8..7631dc5a9b9 100644 --- a/apps/files_external/tests/js/settingsSpec.js +++ b/apps/files_external/tests/js/settingsSpec.js @@ -37,6 +37,7 @@ describe('OCA.External.Settings tests', function() { '<option disable selected>Add storage</option>' + '<option value="\\OC\\TestBackend">Test Backend</option>' + '<option value="\\OC\\AnotherTestBackend">Another Test Backend</option>' + + '<option value="\\OC\\InputsTestBackend">Inputs test backend</option>' + '</select>' + '</td>' + '<td class="authentication"></td>' + @@ -76,6 +77,22 @@ describe('OCA.External.Settings tests', function() { 'builtin': true, }, 'priority': 12 + }, + '\\OC\\InputsTestBackend': { + 'identifier': '\\OC\\InputsTestBackend', + 'name': 'Inputs test backend', + 'configuration': { + 'field_text': 'Text field', + 'field_password': '*Password field', + 'field_bool': '!Boolean field', + 'field_hidden': '#Hidden field', + 'field_text_optional': '&Text field optional', + 'field_password_optional': '&*Password field optional' + }, + 'authSchemes': { + 'builtin': true, + }, + 'priority': 13 } } ); @@ -190,13 +207,70 @@ describe('OCA.External.Settings tests', function() { expect(fakeServer.requests.length).toEqual(1); }); // TODO: tests with "applicableUsers" and "applicableGroups" - // TODO: test with non-optional config parameters // TODO: test with missing mount point value // TODO: test with personal mounts (no applicable fields) // TODO: test save triggers: paste, keyup, checkbox // TODO: test "custom" field with addScript // TODO: status indicator }); + describe('validate storage configuration', function() { + var $tr; + + beforeEach(function() { + $tr = view.$el.find('tr:first'); + selectBackend('\\OC\\InputsTestBackend'); + }); + + it('lists missing fields in storage errors', function() { + var storage = view.getStorageConfig($tr); + + expect(storage.errors).toEqual({ + backendOptions: ['field_text', 'field_password'] + }); + }); + + it('highlights missing non-optional fields', function() { + _.each([ + 'field_text', + 'field_password' + ], function(param) { + expect($tr.find('input[data-parameter='+param+']').hasClass('warning-input')).toBe(true); + }); + _.each([ + 'field_bool', + 'field_hidden', + 'field_text_optional', + 'field_password_optional' + ], function(param) { + expect($tr.find('input[data-parameter='+param+']').hasClass('warning-input')).toBe(false); + }); + }); + + it('validates correct storage', function() { + $tr.find('[name=mountPoint]').val('mountpoint'); + + $tr.find('input[data-parameter=field_text]').val('foo'); + $tr.find('input[data-parameter=field_password]').val('bar'); + $tr.find('input[data-parameter=field_text_optional]').val('foobar'); + // don't set field_password_optional + $tr.find('input[data-parameter=field_hidden]').val('baz'); + + var storage = view.getStorageConfig($tr); + + expect(storage.validate()).toBe(true); + }); + + it('checks missing mount point', function() { + $tr.find('[name=mountPoint]').val(''); + + $tr.find('input[data-parameter=field_text]').val('foo'); + $tr.find('input[data-parameter=field_password]').val('bar'); + + var storage = view.getStorageConfig($tr); + + expect(storage.validate()).toBe(false); + }); + }); describe('update storage', function() { // TODO }); |