vendredi 24 septembre 2021

angular typescript write test for random username method

i started learnin Angular and Typescript and i have to test this method but i dont know how to test Random return . if you can help me would really appreciate

botRandName(): string {
        const x: number = Math.floor(Math.random() * 3);
        if (x === 1) return (this.botName = 'player1');
        else if (x === 2) return (this.botName = 'player2');
        else return (this.botName = 'player3');
    }



Aucun commentaire:

Enregistrer un commentaire