});
it('Encodes special characters', function() {
expect(OC.buildQueryString({
- unicode: '汉字',
+ unicode: '汉字'
})).toEqual('unicode=%E6%B1%89%E5%AD%97');
expect(OC.buildQueryString({
b: 'spaace value',
'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;
afterEach(function() {
clock.restore();
window.oc_config = oldConfig;
- loadedStub.restore();
routeStub.restore();
});
it('sends heartbeat half the session lifetime when heartbeat enabled', 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);
session_lifetime: 300
};
window.initCore();
- expect(loadedStub.notCalled).toEqual(true);
expect(routeStub.notCalled).toEqual(true);
expect(counter).toEqual(0);