git.delta.rocks / unique-network / refs/commits / 293d68a70153

difftreelog

source

tests/src/rmrk/setEquippableList.test.ts3.2 KiBsourcehistory
1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';3import {expectTxFailure} from './util/helpers';4import {createCollection, createBase, setEquippableList} from './util/tx';56describe("integration test: set slot's Equippable List", () => {7  let api: any;8  before(async function () {9    api = await getApiConnection();10    await requirePallets(this, [Pallets.RmrkCore]);11  });1213  const alice = '//Alice';14  const bob = '//Bob';1516  it("set Base's slot Equippable List", async () => {17    const collectionIds = [18      await createCollection(19        api,20        alice,21        'equiplist-collection-metadata',22        null,23        'equiplist-0',24      ),25      await createCollection(26        api,27        alice,28        'equiplist-collection-metadata',29        null,30        'equiplist-1',31      ),32    ];3334    const slotId = 202;3536    const baseId = await createBase(api, alice, 'slotpartany-base-type', 'slotpartany', [37      {38        'SlotPart': {39          id: slotId,40          equippable: 'All',41          z: 1,42          src: 'some-fallback-slot-url',43        },44      },45    ]);4647    await setEquippableList(api, alice, baseId, slotId, 'All');48    await setEquippableList(api, alice, baseId, slotId, 'Empty');49    await setEquippableList(api, alice, baseId, slotId, {'Custom': collectionIds});50  });5152  it('[negative] unable to set equippable list of a slot of non-existing base', async () => {53    const maxBaseId = 0xFFFFFFFF;54    const slotId = 0;5556    const tx = setEquippableList(api, alice, maxBaseId, slotId, 'All');57    await expectTxFailure(/rmrkEquip\.BaseDoesntExist/, tx);58  });5960  it('[negative] unable to set equippable list by a not-an-owner', async () => {61    const slotId = 42;6263    const baseId = await createBase(api, alice, 'slotpartany-base-type', 'slotpartany', [64      {65        'SlotPart': {66          id: slotId,67          equippable: 'All',68          z: 1,69          src: 'some-fallback-slot-url',70        },71      },72    ]);7374    const tx = setEquippableList(api, bob, baseId, slotId, 'All');75    await expectTxFailure(/rmrkEquip\.PermissionError/, tx);76  });7778  it('[negative] unable to set equippable list to a fixed part', async () => {79    const fixedPartId = 42;8081    const baseId = await createBase(api, alice, 'fixedpart-base-type', 'fixedpart', [82      {83        'FixedPart': {84          id: fixedPartId,85          z: 0,86          src: 'fixed-part-url',87        },88      },89    ]);9091    const tx = setEquippableList(api, alice, baseId, fixedPartId, 'All');92    await expectTxFailure(/rmrkEquip\.NoEquippableOnFixedPart/, tx);93  });9495  it('[negative] unable to set equippable list to non-existing slot', async () => {96    const slotId = 777;97    const maxSlotId = 0xFFFFFFFF;9899    const baseId = await createBase(api, alice, 'slotpartany-base-type', 'slotpartany', [100      {101        'SlotPart': {102          id: slotId,103          equippable: 'All',104          z: 1,105          src: 'some-fallback-slot-url',106        },107      },108    ]);109110    const tx = setEquippableList(api, alice, baseId, maxSlotId, 'All');111    await expectTxFailure(/rmrkEquip\.PartDoesntExist/, tx);112  });113114  after(() => { api.disconnect(); });115});