"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const PermissionLevel_1 = require("@wireio/sdk-core/chain/PermissionLevel");
const Name_1 = require("@wireio/sdk-core/chain/Name");
describe("PermissionLevel", () => {
    describe("from string", () => {
        it("parses 'sysio@active' correctly", () => {
            const perm = PermissionLevel_1.PermissionLevel.from("sysio@active");
            expect(String(perm.actor)).toBe("sysio");
            expect(String(perm.permission)).toBe("active");
        });
    });
    describe("from object", () => {
        it("creates from actor/permission object", () => {
            const perm = PermissionLevel_1.PermissionLevel.from({
                actor: "sysio",
                permission: "active"
            });
            expect(String(perm.actor)).toBe("sysio");
            expect(String(perm.permission)).toBe("active");
        });
    });
    describe("field types", () => {
        it("actor and permission are Name instances", () => {
            const perm = PermissionLevel_1.PermissionLevel.from("sysio@active");
            expect(perm.actor).toBeInstanceOf(Name_1.Name);
            expect(perm.permission).toBeInstanceOf(Name_1.Name);
        });
    });
    describe("equals", () => {
        it("returns true for equal permission levels", () => {
            const a = PermissionLevel_1.PermissionLevel.from("sysio@active");
            const b = PermissionLevel_1.PermissionLevel.from("sysio@active");
            expect(a.equals(b)).toBe(true);
        });
        it("returns false for different permission levels", () => {
            const a = PermissionLevel_1.PermissionLevel.from("sysio@active");
            const b = PermissionLevel_1.PermissionLevel.from("sysio@owner");
            expect(a.equals(b)).toBe(false);
        });
        it("accepts string argument", () => {
            const perm = PermissionLevel_1.PermissionLevel.from("sysio@active");
            expect(perm.equals("sysio@active")).toBe(true);
        });
    });
    describe("toString", () => {
        it("returns 'sysio@active'", () => {
            const perm = PermissionLevel_1.PermissionLevel.from("sysio@active");
            expect(perm.toString()).toBe("sysio@active");
        });
        it("returns correct format for other values", () => {
            const perm = PermissionLevel_1.PermissionLevel.from("alice@owner");
            expect(perm.toString()).toBe("alice@owner");
        });
    });
});
//# sourceMappingURL=PermissionLevel.test.js.map