From fa55cf17273426e4242928844def711317761b01 Mon Sep 17 00:00:00 2001 From: kpozdnikin Date: Mon, 11 Jan 2021 12:48:36 +0000 Subject: [PATCH] tests fixes --- --- a/tests/src/setCollectionLimits.test.ts +++ b/tests/src/setCollectionLimits.test.ts @@ -3,7 +3,7 @@ import { IKeyringPair } from '@polkadot/types/types'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import usingApi, { submitTransactionAsync } from './substrate/substrate-api'; +import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api'; import { ICollectionInterface } from './types'; import { createCollectionExpectSuccess, getCreatedCollectionCount, @@ -33,7 +33,6 @@ it('choose or create collection for testing', async () => { await usingApi(async () => { collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'}); - console.log('collectionIdForTesting', collectionIdForTesting); }); }); }); @@ -96,12 +95,7 @@ tokenLimit, }, ); - try { - await submitTransactionAsync(alice, tx); - } catch (e) { - // tslint:disable-next-line:no-unused-expression - expect(e).to.be.exist; - } + await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected; }); }); it('execute setCollectionLimits from user who is not owner of this collection', async () => { @@ -115,12 +109,7 @@ tokenLimit, }, ); - try { - await submitTransactionAsync(bob, tx); - } catch (e) { - // tslint:disable-next-line:no-unused-expression - expect(e).to.be.exist; - } + await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected; }); }); it('execute setCollectionLimits with incorrect limits', async () => { @@ -134,12 +123,7 @@ tokenLimit: '-100', }, ); - try { - await submitTransactionAsync(alice, tx); - } catch (e) { - // tslint:disable-next-line:no-unused-expression - expect(e).to.be.exist; - } + await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected; }); }); }); --- a/tests/src/setSchemaVersion.test.ts +++ b/tests/src/setSchemaVersion.test.ts @@ -4,7 +4,7 @@ import BN from 'bn.js'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import usingApi, { submitTransactionAsync } from './substrate/substrate-api'; +import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api'; import { ICollectionInterface } from './types'; import { createCollectionExpectSuccess, @@ -92,12 +92,13 @@ const collectionCount = await getCreatedCollectionCount(api); const nonExistedCollectionId = collectionCount + 1; tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL'); - try { + await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected; + /*try { await submitTransactionAsync(alice, tx); } catch (e) { // tslint:disable-next-line:no-unused-expression expect(e).to.be.exist; - } + }*/ }); }); @@ -116,13 +117,15 @@ it('execute setSchemaVersion for deleted collection', async () => { await usingApi(async (api: ApiPromise) => { await destroyCollectionExpectSuccess(collectionIdForTesting); - try { + tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL'); + await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected; + /*try { tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL'); await submitTransactionAsync(alice, tx); } catch (e) { // tslint:disable-next-line:no-unused-expression expect(e).to.be.exist; - } + }*/ }); }); }); -- gitstuff