diff --git a/test/classes/mapping/platform-user.ts b/test/classes/mapping/platform-user.ts index 3075045..4e5ab4c 100644 --- a/test/classes/mapping/platform-user.ts +++ b/test/classes/mapping/platform-user.ts @@ -6,28 +6,43 @@ import chaiAsPromised from "chai-as-promised"; import { INVALID_USER_ID, USER_NOT_LOGGED } from "../../../src/scripts/classes/errors"; // Module from files -import { auth } from "../../helpers"; -import PlatformUser from "../../../src/scripts/classes/mapping/platform-user"; -import { logout } from "../../../src"; +import { PlatformUser } from "../../../src"; +import Shared from "../../../src/scripts/shared"; chai.use(chaiAsPromised); const { expect } = chai; export function suite(): void { + it("Set invalid ID", function setInvalidID() { + const user = new PlatformUser(); + expect(user.setID(-1)).to.be.rejectedWith(INVALID_USER_ID); + }); + + it("Set null ID", function setNullID() { + const user = new PlatformUser(); + expect(user.setID(null)).to.be.rejectedWith(INVALID_USER_ID); + }); + it("Fetch platform user without ID", async function fetchWithoutID() { - await auth(); + Shared.setIsLogged(true); const user = new PlatformUser(); await expect(user.fetch()).to.be.rejectedWith(INVALID_USER_ID); }); + it("Fetch platform user with null ID", async function fetchWithNullID() { + Shared.setIsLogged(true); + const user = new PlatformUser(null); + await expect(user.fetch()).to.be.rejectedWith(INVALID_USER_ID); + }); + it("Fetch platform user with invalid ID", async function fetchWithInvalidID() { - await auth(); + Shared.setIsLogged(true); const user = new PlatformUser(-1); await expect(user.fetch()).to.be.rejectedWith(INVALID_USER_ID); }); it("Fetch platform user without authentication", async function fetchWithoutAuth() { - await logout(); + Shared.setIsLogged(false); const user = new PlatformUser(1234); await expect(user.fetch()).to.be.rejectedWith(USER_NOT_LOGGED); });