summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <Raydiation@users.noreply.github.com>2015-05-22 19:08:17 +0200
committerBernhard Posselt <Raydiation@users.noreply.github.com>2015-05-22 19:08:17 +0200
commit13592921f19026f587e01a3a6f1384ca914a62d2 (patch)
tree0fb056d4526a0fe0c54fec10b96bc4ae479b9e82
parentce34edacfa8fbc4f7340b4eb1ad65b35791a95e5 (diff)
parent914c74ea9b21c26da3e033591eec855d0e4d5857 (diff)
downloadnextcloud-server-13592921f19026f587e01a3a6f1384ca914a62d2.tar.gz
nextcloud-server-13592921f19026f587e01a3a6f1384ca914a62d2.zip
Merge pull request #16536 from rullzer/unit_tests_16511
Unit tests for #16511
-rw-r--r--core/js/tests/specs/shareSpec.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index c075351b9f5..33090bbda74 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -110,6 +110,86 @@ describe('OC.Share tests', function() {
describe('Share with link', function() {
// TODO: test ajax calls
// TODO: test password field visibility (whenever enforced or not)
+ it('update password on focus out', function() {
+ $('#allowShareWithLink').val('yes');
+
+ OC.Share.showDropDown(
+ 'file',
+ 123,
+ $container,
+ true,
+ 31,
+ 'shared_file_name.txt'
+ );
+
+ // Toggle linkshare
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ // Enable password, enter password and focusout
+ $('#dropdown [name=showPassword]').click();
+ $('#dropdown #linkPassText').focus();
+ $('#dropdown #linkPassText').val('foo');
+ $('#dropdown #linkPassText').focusout();
+
+ expect(fakeServer.requests[1].method).toEqual('POST');
+ var body = OC.parseQueryString(fakeServer.requests[1].requestBody);
+ expect(body['shareWith']).toEqual('foo');
+
+ // Set password response
+ fakeServer.requests[1].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ expect($('#dropdown #linkPassText').val()).toEqual('');
+ expect($('#dropdown #linkPassText').attr('placeholder')).toEqual('Password protected');
+ });
+ it('update password on enter', function() {
+ $('#allowShareWithLink').val('yes');
+
+ OC.Share.showDropDown(
+ 'file',
+ 123,
+ $container,
+ true,
+ 31,
+ 'shared_file_name.txt'
+ );
+
+ // Toggle linkshare
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ // Enable password and enter password
+ $('#dropdown [name=showPassword]').click();
+ $('#dropdown #linkPassText').focus();
+ $('#dropdown #linkPassText').val('foo');
+ $('#dropdown #linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+
+ expect(fakeServer.requests[1].method).toEqual('POST');
+ var body = OC.parseQueryString(fakeServer.requests[1].requestBody);
+ expect(body['shareWith']).toEqual('foo');
+
+ // Set password response
+ fakeServer.requests[1].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ expect($('#dropdown #linkPassText').val()).toEqual('');
+ expect($('#dropdown #linkPassText').attr('placeholder')).toEqual('Password protected');
+ });
it('shows share with link checkbox when allowed', function() {
$('#allowShareWithLink').val('yes');
OC.Share.showDropDown(