123456import {default as usingApi} from './substrate/substrate-api';7import chai from 'chai';8import {Keyring} from '@polkadot/api';9import {IKeyringPair} from '@polkadot/types/types';10import {11 createCollectionExpectSuccess,12 createItemExpectSuccess,13 addCollectionAdminExpectSuccess,14} from './util/helpers';1516const expect = chai.expect;17let alice: IKeyringPair;18let bob: IKeyringPair;1920describe('integration test: ext. createItem():', () => {21 before(async () => {22 await usingApi(async () => {23 const keyring = new Keyring({type: 'sr25519'});24 alice = keyring.addFromUri('//Alice');25 bob = keyring.addFromUri('//Bob');26 });27 });2829 it('Create new item in NFT collection', async () => {30 const createMode = 'NFT';31 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});32 await createItemExpectSuccess(alice, newCollectionID, createMode);33 });34 it('Create new item in Fungible collection', async () => {35 const createMode = 'Fungible';36 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});37 await createItemExpectSuccess(alice, newCollectionID, createMode);38 });39 it('Create new item in ReFungible collection', async () => {40 const createMode = 'ReFungible';41 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});42 await createItemExpectSuccess(alice, newCollectionID, createMode);43 });44 it('Create new item in NFT collection with collection admin permissions', async () => {45 const createMode = 'NFT';46 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});47 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);48 await createItemExpectSuccess(bob, newCollectionID, createMode);49 });50 it('Create new item in Fungible collection with collection admin permissions', async () => {51 const createMode = 'Fungible';52 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});53 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);54 await createItemExpectSuccess(bob, newCollectionID, createMode);55 });56 it('Create new item in ReFungible collection with collection admin permissions', async () => {57 const createMode = 'ReFungible';58 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});59 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);60 await createItemExpectSuccess(bob, newCollectionID, createMode);61 });62});6364describe('Negative integration test: ext. createItem():', () => {65 before(async () => {66 await usingApi(async () => {67 const keyring = new Keyring({type: 'sr25519'});68 alice = keyring.addFromUri('//Alice');69 bob = keyring.addFromUri('//Bob');70 });71 });7273 it('Regular user cannot create new item in NFT collection', async () => {74 const createMode = 'NFT';75 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});76 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;77 });78 it('Regular user cannot create new item in Fungible collection', async () => {79 const createMode = 'Fungible';80 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});81 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;82 });83 it('Regular user cannot create new item in ReFungible collection', async () => {84 const createMode = 'ReFungible';85 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});86 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;87 });88});