Skip to content

Commit

Permalink
Fixing Cui.Session
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Mar 14, 2024
1 parent c31b7d2 commit 5af6898
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
4 changes: 1 addition & 3 deletions web-modules/cui-javascript/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ module.exports = function(grunt) {


// Default task(s).
grunt.registerTask('default', ['clean', 'ts', 'jshint', 'uglify']);
// TODO owo:Aus irgendeinem Grund wird das chromium plugin nicht mehr geladen, daher auskommentiert
// grunt.registerTask('default', ['clean', 'ts', 'jshint', 'uglify', 'jasmine']);
grunt.registerTask('default', ['clean', 'ts', 'jshint', 'uglify', 'jasmine']);

};
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
namespace Cui {

export class Session {
private timeout: ReturnType<typeof setTimeout>;
private interval: number;
private id: string;
private static timeout: ReturnType<typeof setTimeout>;
private static interval: number;
private static id: string;

/**
* initialize logout timeout
* @intervalSec : int value in seconds
* @logoutUrl : logout url to redirect to
* @callback : function to execute after timout exceeded
*/
public startLogoutTimeout(intervalSec: number, linkId: string, callback?: () => void): void {
public static startLogoutTimeout(intervalSec: number, linkId: string, callback?: () => void): void {
this.interval = (intervalSec === undefined ? 1 : intervalSec) * 1000;
this.id = linkId;
this.setLogoutTimeout(callback);
Expand All @@ -24,7 +24,7 @@ namespace Cui {
/**
* set logout timeout
*/
private setLogoutTimeout(callback?: () => void): void {
private static setLogoutTimeout(callback?: () => void): void {
if (callback) {
if (this.interval > 0) {
this.timeout = setTimeout(callback, this.interval);
Expand All @@ -41,15 +41,15 @@ namespace Cui {
/**
* reset logout timeout
*/
public resetLogoutTimeout(): void {
public static resetLogoutTimeout(): void {
this.stopLogoutTimeout();
this.setLogoutTimeout();
}

/**
* reset logout timeout
*/
public stopLogoutTimeout(): void {
public static stopLogoutTimeout(): void {
clearTimeout(this.timeout);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Component enabler", function() {
class CallBack {
called = 0;
callback() {
this.called++;
this.called++;
}
}
it("Should register component enabler and call callback", function () {
Expand Down Expand Up @@ -107,16 +107,12 @@ describe("Condition with boolean parser", function() {
});
it("exactly false shouldn't go into true condition", function() {
let i = 0;
if (false) {
i = 1;
}

expect(i).toEqual(0);
});
it("exactly true should go into true condition", function() {
let i = 0;
if (true) {
i = 1;
}
i = 1;
expect(i).toEqual(1);
});
it("and w/o equal shouldn't go into true condition", function() {
Expand All @@ -137,21 +133,22 @@ describe("Condition with boolean parser", function() {
});
});

// describe("Session", function() {
// it("should start", function() {
// Cui.Session.startLogoutTimeout();
// expect(true).toEqual(true);
// });
// /*
// * Remove the following two methods to test refresh.
// */
// it("should reset", function() {
// Cui.Session.resetLogoutTimeout();
// expect(true).toEqual(true);
// });
// it("should stop", function() {
// Cui.Session.stopLogoutTimeout();
// expect(true).toEqual(true);
// });
// });
describe("Session", function() {
it("should start", function() {
Cui.Session.startLogoutTimeout();
expect(true).toEqual(true);
});
/*
* Remove the following two methods to test refresh.
*/
it("should reset", function() {
Cui.Session.resetLogoutTimeout();
expect(true).toEqual(true);
});
it("should stop", function() {
Cui.Session.stopLogoutTimeout();
expect(true).toEqual(true);
});
});


0 comments on commit 5af6898

Please sign in to comment.