lundi 29 juin 2020

how to write unit testing in angular for DOM events with set Interval

inactivityTime = () => {
        this.events.forEach(event => {
        document[event] = () => {
            this.idleTime = false;
        };
    });
    const timeout = () => {
        if (this.idleTime) {
            console.log('Call API to kill session');
        }
        this.idleTime = true;
    };
    setInterval(timeout, 90000);

i have to write unit test for above function where set Timeout is called for inactivity period how to do that.

inactivityTime = () => {
            this.events.forEach(event => {
            document[event] = () => {
                this.idleTime = false;
            };
        });
        const timeout = () => {
            if (this.idleTime) {
                console.log('Call API to kill session');
            }
            this.idleTime = true;
        };
        setInterval(timeout, 90000);
i have to write unit test for above function where set Timeout is called for inactivity period how to do that.

Aucun commentaire:

Enregistrer un commentaire