"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Variant_1 = require("@wireio/sdk-core/chain/Variant");
const Name_1 = require("@wireio/sdk-core/chain/Name");
const Integer_1 = require("@wireio/sdk-core/chain/Integer");
let MyVariant = class MyVariant extends Variant_1.Variant {
};
MyVariant = __decorate([
    Variant_1.Variant.type("my_variant", [Name_1.Name, Integer_1.UInt64])
], MyVariant);
describe("Variant", () => {
    describe("from", () => {
        it("creates a variant with a Name value", () => {
            const v = MyVariant.from(["name", "alice"]);
            expect(v).toBeInstanceOf(MyVariant);
            expect(v.variantIdx).toBe(0);
            expect(v.value).toBeInstanceOf(Name_1.Name);
            expect(String(v.value)).toBe("alice");
        });
        it("creates a variant with a UInt64 value", () => {
            const v = MyVariant.from(["uint64", 42]);
            expect(v).toBeInstanceOf(MyVariant);
            expect(v.variantIdx).toBe(1);
        });
    });
    describe("equals", () => {
        it("returns true for equal variants", () => {
            const a = MyVariant.from(["name", "alice"]);
            const b = MyVariant.from(["name", "alice"]);
            expect(a.equals(b)).toBe(true);
        });
        it("returns false for different variant types", () => {
            const a = MyVariant.from(["name", "alice"]);
            const b = MyVariant.from(["uint64", 42]);
            expect(a.equals(b)).toBe(false);
        });
    });
    describe("variantName", () => {
        it("returns the name of the active variant type", () => {
            const v = MyVariant.from(["name", "alice"]);
            expect(v.variantName).toBe("name");
        });
    });
    describe("decorator", () => {
        it("registers ABI name via Variant.type", () => {
            expect(MyVariant.abiName).toBe("my_variant");
        });
        it("registers variant types", () => {
            expect(MyVariant.abiVariant).toBeDefined();
            expect(MyVariant.abiVariant.length).toBe(2);
        });
    });
});
//# sourceMappingURL=Variant.test.js.map