diff options
author | Abijeet <abijeetpatro@gmail.com> | 2018-01-06 18:05:23 +0530 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-01-10 16:41:27 +0100 |
commit | b246ca96ffe45bfad8fbcc744be6d2e158228987 (patch) | |
tree | 30f721b21c6b9eae518da28d95294e114c5c79f4 /core/js | |
parent | de5467811a52abcc16d0b536136e09f1b614d79c (diff) | |
download | nextcloud-server-b246ca96ffe45bfad8fbcc744be6d2e158228987.tar.gz nextcloud-server-b246ca96ffe45bfad8fbcc744be6d2e158228987.zip |
Added test cases for the fix for the password confirmation box appearing repeatedly.
Signed-off-by: Abijeet <abijeetpatro@gmail.com>
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index b6c617303cf..b27294b0f32 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -1539,4 +1539,41 @@ describe('Core base tests', function() { expect(snapperStub.close.calledTwice).toBe(true); }); }); + describe('Requires password confirmation', function () { + var stubMomentNow; + var stubJsPageLoadTime; + + afterEach(function () { + delete window.nc_pageLoad; + delete window.nc_lastLogin; + delete window.backendAllowsPasswordConfirmation; + + stubMomentNow.restore(); + stubJsPageLoadTime.restore(); + }); + + it('should not show the password confirmation dialog', function () { + // add server variables + window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000); + window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000); + window.backendAllowsPasswordConfirmation = true; + + stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime()); + stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 20, 0).getTime()); + + expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy(); + }); + + it('should show the password confirmation dialog', function () { + // add server variables + window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000); + window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000); + window.backendAllowsPasswordConfirmation = true; + + stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime()); + stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 31, 0).getTime()); + + expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy(); + }); + }); }); |