aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/tests/specs/sharedialogviewSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js/tests/specs/sharedialogviewSpec.js')
-rw-r--r--core/js/tests/specs/sharedialogviewSpec.js186
1 files changed, 2 insertions, 184 deletions
diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js
index 5fd920a758c..33d3be51440 100644
--- a/core/js/tests/specs/sharedialogviewSpec.js
+++ b/core/js/tests/specs/sharedialogviewSpec.js
@@ -214,188 +214,6 @@ describe('OC.Share.ShareDialogView', function() {
focusStub.restore();
selectStub.restore();
});
- describe('password', function() {
- var slideToggleStub;
-
- beforeEach(function() {
- $('#allowShareWithLink').val('yes');
- configModel.set({
- enforcePasswordForPublicLink: false
- });
-
- slideToggleStub = sinon.stub($.fn, 'slideToggle');
- });
- afterEach(function() {
- slideToggleStub.restore();
- });
-
- it('enforced but toggled does not fire request', function() {
- configModel.set('enforcePasswordForPublicLink', true);
- dialog.render();
-
- dialog.$el.find('.linkCheckbox').click();
-
- // The password linkPass field is shown (slideToggle is called).
- // No request is made yet
- expect(slideToggleStub.callCount).toEqual(1);
- expect(slideToggleStub.getCall(0).thisValue.eq(0).attr('id')).toEqual('linkPass');
- expect(fakeServer.requests.length).toEqual(0);
-
- // Now untoggle share by link
- dialog.$el.find('.linkCheckbox').click();
- dialog.render();
-
- // Password field disappears and no ajax requests have been made
- expect(fakeServer.requests.length).toEqual(0);
- expect(slideToggleStub.callCount).toEqual(2);
- expect(slideToggleStub.getCall(1).thisValue.eq(0).attr('id')).toEqual('linkPass');
- });
- });
- describe('expiration date', function() {
- var shareData;
- var shareItem;
- var clock;
- var expectedMinDate;
-
- beforeEach(function() {
- // pick a fake date
- clock = sinon.useFakeTimers(new Date(2014, 0, 20, 14, 0, 0).getTime());
- expectedMinDate = new Date(2014, 0, 21, 14, 0, 0);
-
- configModel.set({
- enforcePasswordForPublicLink: false,
- isDefaultExpireDateEnabled: false,
- isDefaultExpireDateEnforced: false,
- defaultExpireDate: 7
- });
-
- shareModel.set('linkShare', {
- isLinkShare: true,
- token: 'tehtoken',
- permissions: OC.PERMISSION_READ,
- expiration: null
- });
- });
- afterEach(function() {
- clock.restore();
- });
-
- it('does not check expiration date checkbox when no date was set', function() {
- shareModel.get('linkShare').expiration = null;
- dialog.render();
-
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(false);
- expect(dialog.$el.find('.datepicker').val()).toEqual('');
- });
- it('does not check expiration date checkbox for new share', function() {
- dialog.render();
-
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(false);
- expect(dialog.$el.find('.datepicker').val()).toEqual('');
- });
- it('checks expiration date checkbox and populates field when expiration date was set', function() {
- shareModel.get('linkShare').expiration = '2014-02-01 00:00:00';
- dialog.render();
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
- expect(dialog.$el.find('.datepicker').val()).toEqual('01-02-2014');
- });
- it('sets default date when default date setting is enabled', function() {
- configModel.set('isDefaultExpireDateEnabled', true);
- dialog.render();
- dialog.$el.find('.linkCheckbox').click();
- // here fetch would be called and the server returns the expiration date
- shareModel.get('linkShare').expiration = '2014-1-27 00:00:00';
- dialog.render();
-
- // enabled by default
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
- expect(dialog.$el.find('.datepicker').val()).toEqual('27-01-2014');
-
- // disabling is allowed
- dialog.$el.find('[name=expirationCheckbox]').click();
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(false);
- });
- it('enforces default date when enforced date setting is enabled', function() {
- configModel.set({
- isDefaultExpireDateEnabled: true,
- isDefaultExpireDateEnforced: true
- });
- dialog.render();
- dialog.$el.find('.linkCheckbox').click();
- // here fetch would be called and the server returns the expiration date
- shareModel.get('linkShare').expiration = '2014-1-27 00:00:00';
- dialog.render();
-
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
- expect(dialog.$el.find('.datepicker').val()).toEqual('27-01-2014');
-
- // disabling is not allowed
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('disabled')).toEqual(true);
- dialog.$el.find('[name=expirationCheckbox]').click();
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
- });
- it('enforces default date when enforced date setting is enabled and password is enforced', function() {
- configModel.set({
- enforcePasswordForPublicLink: true,
- isDefaultExpireDateEnabled: true,
- isDefaultExpireDateEnforced: true
- });
- dialog.render();
- dialog.$el.find('.linkCheckbox').click();
- // here fetch would be called and the server returns the expiration date
- shareModel.get('linkShare').expiration = '2014-1-27 00:00:00';
- dialog.render();
-
- //Enter password
- dialog.$el.find('.linkPassText').val('foo');
- dialog.$el.find('.linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
- fakeServer.requests[0].respond(
- 200,
- { 'Content-Type': 'application/json' },
- JSON.stringify({data: {token: 'xyz'}, status: 'success'})
- );
-
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
- expect(dialog.$el.find('.datepicker').val()).toEqual('27-01-2014');
-
- // disabling is not allowed
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('disabled')).toEqual(true);
- dialog.$el.find('[name=expirationCheckbox]').click();
- expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
- });
- it('sets picker minDate to today and no maxDate by default', function() {
- dialog.render();
- dialog.$el.find('.linkCheckbox').click();
- dialog.$el.find('[name=expirationCheckbox]').click();
- expect($.datepicker._defaults.minDate).toEqual(expectedMinDate);
- expect($.datepicker._defaults.maxDate).toEqual(null);
- });
- it('limits the date range to X days after share time when enforced', function() {
- configModel.set({
- isDefaultExpireDateEnabled: true,
- isDefaultExpireDateEnforced: true
- });
- dialog.render();
- dialog.$el.find('.linkCheckbox').click();
- expect($.datepicker._defaults.minDate).toEqual(expectedMinDate);
- expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0));
- });
- it('limits the date range to X days after share time when enforced, even when redisplayed the next days', function() {
- // item exists, was created two days ago
- var shareItem = shareModel.get('linkShare');
- shareItem.expiration = '2014-1-27';
- // share time has time component but must be stripped later
- shareItem.stime = new Date(2014, 0, 20, 11, 0, 25).getTime() / 1000;
- configModel.set({
- isDefaultExpireDateEnabled: true,
- isDefaultExpireDateEnforced: true
- });
- dialog.render();
- expect($.datepicker._defaults.minDate).toEqual(expectedMinDate);
- expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0));
- });
- });
-
});
describe('check for avatar', function() {
beforeEach(function() {
@@ -455,8 +273,8 @@ describe('OC.Share.ShareDialogView', function() {
it('test correct function calls', function() {
expect(avatarStub.calledThrice).toEqual(true);
expect(placeholderStub.callCount).toEqual(4);
- expect(dialog.$('.shareWithList').children().length).toEqual(5);
- expect(dialog.$('.avatar').length).toEqual(6);
+ expect(dialog.$('.shareWithList').children().length).toEqual(6);
+ expect(dialog.$('.avatar').length).toEqual(7);
});
it('test avatar owner', function() {