difftreelog
Missing tests added
in: master
6 files changed
tests/src/addToWhiteList.test.tsdiffbeforeafterboth17 enableWhiteListExpectSuccess,17 enableWhiteListExpectSuccess,18 normalizeAccountId,18 normalizeAccountId,19 addCollectionAdminExpectSuccess,19 addCollectionAdminExpectSuccess,20 addToWhiteListExpectFail,20} from './util/helpers';21} from './util/helpers';212222chai.use(chaiAsPromised);23chai.use(chaiAsPromised);98 });99 });99 });100 });101102 it('Add to the white list by regular user', async () => {103 const collectionId = await createCollectionExpectSuccess();104 await addToWhiteListExpectFail(Bob, collectionId, Charlie.address);105 });100106101 it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {107 it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {102 const collectionId = await createCollectionExpectSuccess();108 const collectionId = await createCollectionExpectSuccess();tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth37 });37 });38 });38 });3940 it('Remove collection admin by admin.', async () => {41 await usingApi(async (api: ApiPromise) => {42 const collectionId = await createCollectionExpectSuccess();43 const Alice = privateKey('//Alice');44 const Bob = privateKey('//Bob');45 const Charlie = privateKey('//Charlie');46 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();47 expect(collection.Owner).to.be.deep.eq(Alice.address);48 // first - add collection admin Bob49 const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));50 await submitTransactionAsync(Alice, addAdminTx);5152 const addAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));53 await submitTransactionAsync(Alice, addAdminTx2);5455 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON();56 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(Bob.address));5758 // then remove bob from admins of collection59 const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));60 await submitTransactionAsync(Charlie, removeAdminTx);6162 const adminListAfterRemoveAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON;63 expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(Bob.address));64 });65 });396640 it('Remove admin from collection that has no admins', async () => {67 it('Remove admin from collection that has no admins', async () => {41 await usingApi(async (api: ApiPromise) => {68 await usingApi(async (api: ApiPromise) => {tests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth112 await removeCollectionSponsorExpectFailure(collectionId, '//Bob');112 await removeCollectionSponsorExpectFailure(collectionId, '//Bob');113 });113 });114115 it('(!negative test!) Remove sponsor for a collection by regular user', async () => {116 const collectionId = await createCollectionExpectSuccess();117 await setCollectionSponsorExpectSuccess(collectionId, bob.address);118 await removeCollectionSponsorExpectFailure(collectionId, '//Bob');119 });114120115 it('(!negative test!) Remove sponsor in a destroyed collection', async () => {121 it('(!negative test!) Remove sponsor in a destroyed collection', async () => {116 const collectionId = await createCollectionExpectSuccess();122 const collectionId = await createCollectionExpectSuccess();tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth125 });125 });126 });126 });127128 it('Regular user can`t remove from whitelist', async () => {129 await usingApi(async () => {130 const collectionWithoutWhitelistId = await createCollectionExpectSuccess();131 await enableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);132 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, charlie.address);133 await removeFromWhiteListExpectFailure(bob, collectionWithoutWhitelistId, normalizeAccountId(charlie.address));134 });135 });127});136});tests/src/setSchemaVersion.test.tsdiffbeforeafterboth242425let alice: IKeyringPair;25let alice: IKeyringPair;26let bob: IKeyringPair;26let bob: IKeyringPair;27let charlie: IKeyringPair;27let collectionIdForTesting: number;28let collectionIdForTesting: number;282929/*30/*111 });112 });112});113});113114114describe('setSchemaVersion negative', () => {115describe.only('setSchemaVersion negative', () => {115 let tx;116 let tx;116 before(async () => {117 before(async () => {117 await usingApi(async () => {118 await usingApi(async () => {118 const keyring = new Keyring({ type: 'sr25519' });119 const keyring = new Keyring({ type: 'sr25519' });119 alice = keyring.addFromUri('//Alice');120 alice = keyring.addFromUri('//Alice');121 charlie = keyring.addFromUri('//Charlie');120 });122 });121 });123 });122 it('execute setSchemaVersion for not exists collection', async () => {124 it('execute setSchemaVersion for not exists collection', async () => {151 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;151 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;152 });152 });153 });153 });154 it('Regular user can`t execute setSchemaVersion with image url and unique ', async () => {155 await usingApi(async (api: ApiPromise) => {156 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');157 await expect(submitTransactionAsync(charlie, tx)).to.be.rejected;158 });159 });154});160});155161tests/src/util/helpers.tsdiffbeforeafterboth1088 });1088 });1089}1089}10901091export async function addToWhiteListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1092 await usingApi(async (api) => {1093 // Run the transaction1094 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1095 const events = await expect(submitTransactionAsync(sender, tx)).to.be.rejected;1096 const result = getGenericResult(events);10971098 // What to expect1099 // tslint:disable-next-line:no-unused-expression1100 expect(result.success).to.be.false;1101 });1102}109011031091export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1104export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1092 await usingApi(async (api) => {1105 await usingApi(async (api) => {