mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fixing js unit tests
This commit is contained in:
parent
5f711912a1
commit
33b798c3d6
3 changed files with 5 additions and 11 deletions
|
|
@ -17,7 +17,6 @@
|
|||
"eventsource.js",
|
||||
"config.js",
|
||||
"multiselect.js",
|
||||
"router.js",
|
||||
"oc-requesttoken.js"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ window.oc_defaults = {};
|
|||
// custom responses
|
||||
window.fakeServer = fakeServer;
|
||||
|
||||
OC.Router = {};
|
||||
OC.Router.routes = [];
|
||||
OC.Router.routes_request = {
|
||||
state: sinon.stub().returns('resolved'),
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ describe('Core base tests', function() {
|
|||
});
|
||||
it('Encodes special characters', function() {
|
||||
expect(OC.buildQueryString({
|
||||
unicode: '汉字',
|
||||
unicode: '汉字'
|
||||
})).toEqual('unicode=%E6%B1%89%E5%AD%97');
|
||||
expect(OC.buildQueryString({
|
||||
b: 'spaace value',
|
||||
|
|
@ -199,22 +199,20 @@ describe('Core base tests', function() {
|
|||
'booleantrue': true
|
||||
})).toEqual('booleanfalse=false&booleantrue=true');
|
||||
expect(OC.buildQueryString({
|
||||
'number': 123,
|
||||
'number': 123
|
||||
})).toEqual('number=123');
|
||||
});
|
||||
});
|
||||
describe('Session heartbeat', function() {
|
||||
var clock,
|
||||
oldConfig,
|
||||
loadedStub,
|
||||
routeStub,
|
||||
counter;
|
||||
|
||||
beforeEach(function() {
|
||||
clock = sinon.useFakeTimers();
|
||||
oldConfig = window.oc_config;
|
||||
loadedStub = sinon.stub(OC.Router, 'registerLoadedCallback');
|
||||
routeStub = sinon.stub(OC.Router, 'generate').returns('/heartbeat');
|
||||
routeStub = sinon.stub(OC, 'generateUrl').returns('/heartbeat');
|
||||
counter = 0;
|
||||
|
||||
fakeServer.autoRespond = true;
|
||||
|
|
@ -227,7 +225,6 @@ describe('Core base tests', function() {
|
|||
afterEach(function() {
|
||||
clock.restore();
|
||||
window.oc_config = oldConfig;
|
||||
loadedStub.restore();
|
||||
routeStub.restore();
|
||||
});
|
||||
it('sends heartbeat half the session lifetime when heartbeat enabled', function() {
|
||||
|
|
@ -236,9 +233,7 @@ describe('Core base tests', function() {
|
|||
session_lifetime: 300
|
||||
};
|
||||
window.initCore();
|
||||
expect(loadedStub.calledOnce).toEqual(true);
|
||||
loadedStub.yield();
|
||||
expect(routeStub.calledWith('heartbeat')).toEqual(true);
|
||||
expect(routeStub.calledWith('/heartbeat')).toEqual(true);
|
||||
|
||||
expect(counter).toEqual(0);
|
||||
|
||||
|
|
@ -264,7 +259,6 @@ describe('Core base tests', function() {
|
|||
session_lifetime: 300
|
||||
};
|
||||
window.initCore();
|
||||
expect(loadedStub.notCalled).toEqual(true);
|
||||
expect(routeStub.notCalled).toEqual(true);
|
||||
|
||||
expect(counter).toEqual(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue