Add extra test cases for password confirmation

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-01-10 16:42:25 +01:00
parent b246ca96ff
commit 9c22e99331
1 changed files with 26 additions and 2 deletions

View File

@ -1552,7 +1552,7 @@ describe('Core base tests', function() {
stubJsPageLoadTime.restore(); stubJsPageLoadTime.restore();
}); });
it('should not show the password confirmation dialog', function () { it('should not show the password confirmation dialog when server time is earlier than local time', function () {
// add server variables // add server variables
window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000); 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.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000);
@ -1564,7 +1564,7 @@ describe('Core base tests', function() {
expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy(); expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy();
}); });
it('should show the password confirmation dialog', function () { it('should show the password confirmation dialog when server time is earlier than local time', function () {
// add server variables // add server variables
window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000); 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.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000);
@ -1575,5 +1575,29 @@ describe('Core base tests', function() {
expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy(); expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy();
}); });
it('should not show the password confirmation dialog when server time is later than local time', function () {
// add server variables
window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 23, 15, 0).getTime() / 1000);
window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 23, 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 when server time is later than local time', function () {
// add server variables
window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 23, 15, 0).getTime() / 1000);
window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 23, 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();
});
}); });
}); });