Skip to content
Extraits de code Groupes Projets
Valider aa30a2f7 rédigé par Christian Paul's avatar Christian Paul
Parcourir les fichiers

Fix RoomCountLimitReached()

parent 1b8fc58c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -46,7 +46,7 @@ export class Provisioner {
* @returns Has the limit been reached?
*/
public async RoomCountLimitReached(limit: number): Promise<boolean> {
return limit >= 0 && limit >= await this.roomStore.countEntries();
return limit >= 0 && await this.roomStore.countEntries() >= limit;
}
public async UnbridgeChannel(channel: Discord.TextChannel, rId?: string) {
......
......@@ -71,4 +71,30 @@ describe("Provisioner", () => {
expect(await promise).to.eq("Approved");
});
});
describe("RoomCountLimitReached", () => {
it("should return false if no limit is defined", async () => {
const p = new Provisioner({
countEntries: async () => 7,
} as any, {} as any);
expect(await p.RoomCountLimitReached(-1)).to.equal(false);
});
it("should return false if less rooms exist than the limit", async () => {
const p = new Provisioner({
countEntries: async () => 7,
} as any, {} as any);
expect(await p.RoomCountLimitReached(10)).to.equal(false);
});
it("should return true if more rooms exist than the limit", async () => {
const p = new Provisioner({
countEntries: async () => 7,
} as any, {} as any);
expect(await p.RoomCountLimitReached(5)).to.equal(true);
});
it("should return true if there are as many rooms as the limit allows", async () => {
const p = new Provisioner({
countEntries: async () => 7,
} as any, {} as any);
expect(await p.RoomCountLimitReached(7)).to.equal(true);
});
});
});
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter