1234567891011121314151617import {default as usingApi} from './substrate/substrate-api';18import chai from 'chai';19import {Keyring} from '@polkadot/api';20import {IKeyringPair} from '@polkadot/types/types';21import {22 createCollectionExpectSuccess,23 createItemExpectSuccess,24 addCollectionAdminExpectSuccess,25} from './util/helpers';2627const expect = chai.expect;28let alice: IKeyringPair;29let bob: IKeyringPair;3031describe('integration test: ext. createItem():', () => {32 before(async () => {33 await usingApi(async () => {34 const keyring = new Keyring({type: 'sr25519'});35 alice = keyring.addFromUri('//Alice');36 bob = keyring.addFromUri('//Bob');37 });38 });3940 it('Create new item in NFT collection', async () => {41 const createMode = 'NFT';42 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});43 await createItemExpectSuccess(alice, newCollectionID, createMode);44 });45 it('Create new item in Fungible collection', async () => {46 const createMode = 'Fungible';47 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});48 await createItemExpectSuccess(alice, newCollectionID, createMode);49 });50 it('Create new item in ReFungible collection', async () => {51 const createMode = 'ReFungible';52 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});53 await createItemExpectSuccess(alice, newCollectionID, createMode);54 });55 it('Create new item in NFT collection with collection admin permissions', async () => {56 const createMode = 'NFT';57 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});58 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);59 await createItemExpectSuccess(bob, newCollectionID, createMode);60 });61 it('Create new item in Fungible collection with collection admin permissions', async () => {62 const createMode = 'Fungible';63 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});64 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);65 await createItemExpectSuccess(bob, newCollectionID, createMode);66 });67 it('Create new item in ReFungible collection with collection admin permissions', async () => {68 const createMode = 'ReFungible';69 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});70 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);71 await createItemExpectSuccess(bob, newCollectionID, createMode);72 });73});7475describe('Negative integration test: ext. createItem():', () => {76 before(async () => {77 await usingApi(async () => {78 const keyring = new Keyring({type: 'sr25519'});79 alice = keyring.addFromUri('//Alice');80 bob = keyring.addFromUri('//Bob');81 });82 });8384 it('Regular user cannot create new item in NFT collection', async () => {85 const createMode = 'NFT';86 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});87 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;88 });89 it('Regular user cannot create new item in Fungible collection', async () => {90 const createMode = 'Fungible';91 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});92 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;93 });94 it('Regular user cannot create new item in ReFungible collection', async () => {95 const createMode = 'ReFungible';96 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});97 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;98 });99});