summaryrefslogtreecommitdiffstats
path: root/core/js/tests/specs/sharedialoglinkshareview.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js/tests/specs/sharedialoglinkshareview.js')
-rw-r--r--core/js/tests/specs/sharedialoglinkshareview.js113
1 files changed, 113 insertions, 0 deletions
diff --git a/core/js/tests/specs/sharedialoglinkshareview.js b/core/js/tests/specs/sharedialoglinkshareview.js
index f5fe8725c03..c2d84fd2e87 100644
--- a/core/js/tests/specs/sharedialoglinkshareview.js
+++ b/core/js/tests/specs/sharedialoglinkshareview.js
@@ -235,4 +235,117 @@ describe('OC.Share.ShareDialogLinkShareView', function () {
});
+ describe('protect password by Talk', function () {
+
+ var $passwordByTalkCheckbox;
+ var $workingIcon;
+
+ beforeEach(function () {
+ // Needed to render the view
+ configModel.isShareWithLinkAllowed.returns(true);
+
+ // "Enable" Talk
+ window.oc_appswebroots['spreed'] = window.oc_webroot + '/apps/files/';
+
+ shareModel.set({
+ linkShares: [{
+ id: 123,
+ password: 'password'
+ }]
+ });
+ view.render();
+
+ $passwordByTalkCheckbox = view.$el.find('.passwordByTalkCheckbox');
+ $workingIcon = $passwordByTalkCheckbox.prev('.icon-loading-small');
+
+ sinon.stub(shareModel, 'saveLinkShare');
+
+ expect($workingIcon.hasClass('hidden')).toBeTruthy();
+ });
+
+ afterEach(function () {
+ shareModel.saveLinkShare.restore();
+ });
+
+ it('is shown if Talk is enabled and there is a password set', function() {
+ expect($passwordByTalkCheckbox.length).toBeTruthy();
+ });
+
+ it('is not shown if Talk is enabled but there is no password set', function() {
+ // Changing the password value also triggers the rendering
+ shareModel.set({
+ linkShares: [{
+ id: 123
+ }]
+ });
+
+ $passwordByTalkCheckbox = view.$el.find('.passwordByTalkCheckbox');
+
+ expect($passwordByTalkCheckbox.length).toBeFalsy();
+ });
+
+ it('is not shown if there is a password set but Talk is not enabled', function() {
+ // "Disable" Talk
+ delete window.oc_appswebroots['spreed'];
+
+ view.render();
+
+ $passwordByTalkCheckbox = view.$el.find('.passwordByTalkCheckbox');
+
+ expect($passwordByTalkCheckbox.length).toBeFalsy();
+ });
+
+ it('checkbox is checked when the setting is enabled', function () {
+ shareModel.set({
+ linkShares: [{
+ id: 123,
+ password: 'password',
+ sendPasswordByTalk: true
+ }]
+ });
+ view.render();
+
+ $passwordByTalkCheckbox = view.$el.find('.passwordByTalkCheckbox');
+
+ expect($passwordByTalkCheckbox.is(':checked')).toEqual(true);
+ });
+
+ it('checkbox is not checked when the setting is disabled', function () {
+ expect($passwordByTalkCheckbox.is(':checked')).toEqual(false);
+ });
+
+ it('enables the setting if clicked when unchecked', function () {
+ // Simulate the click by checking the checkbox and then triggering
+ // the "change" event.
+ $passwordByTalkCheckbox.prop('checked', true);
+ $passwordByTalkCheckbox.change();
+
+ expect($workingIcon.hasClass('hidden')).toBeFalsy();
+ expect(shareModel.saveLinkShare.withArgs({ sendPasswordByTalk: true, cid: 123 }).calledOnce).toBeTruthy();
+ });
+
+ it('disables the setting if clicked when checked', function () {
+ shareModel.set({
+ linkShares: [{
+ id: 123,
+ password: 'password',
+ sendPasswordByTalk: true
+ }]
+ });
+ view.render();
+
+ $passwordByTalkCheckbox = view.$el.find('.passwordByTalkCheckbox');
+ $workingIcon = $passwordByTalkCheckbox.prev('.icon-loading-small');
+
+ // Simulate the click by unchecking the checkbox and then triggering
+ // the "change" event.
+ $passwordByTalkCheckbox.prop('checked', false);
+ $passwordByTalkCheckbox.change();
+
+ expect($workingIcon.hasClass('hidden')).toBeFalsy();
+ expect(shareModel.saveLinkShare.withArgs({ sendPasswordByTalk: false, cid: 123 }).calledOnce).toBeTruthy();
+ });
+
+ });
+
});