git.delta.rocks / unique-network / refs/commits / 71a792f94904

difftreelog

tests: remove dependency on tests execution order

Yaroslav Bolyukin2021-02-01parent: #6809679.patch.diff
in: master

1 file changed

modifiedtests/src/setMintPermission.test.tsdiffbeforeafterboth
before · tests/src/setMintPermission.test.ts
1import { IKeyringPair } from '@polkadot/types/types';2import privateKey from './substrate/privateKey';3import usingApi from './substrate/substrate-api';4import {5  addToWhiteListExpectSuccess,6  createCollectionExpectSuccess,7  createItemExpectSuccess,8  destroyCollectionExpectSuccess,9  enableWhiteListExpectSuccess,10  findNotExistingCollection,11  setMintPermissionExpectFailure,12  setMintPermissionExpectSuccess,13} from './util/helpers';1415describe('Integration Test setMintPermission', () => {16  let alice: IKeyringPair;17  let bob: IKeyringPair;1819  let collectionId: number;20  before(async () => {21    await usingApi(async () => {22      alice = privateKey('//Alice');23      bob = privateKey('//Bob');2425      collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });26    });27  });2829  it('execute setMintPermission', async () => {30    await usingApi(async () => {31      await enableWhiteListExpectSuccess(alice, collectionId);32      await setMintPermissionExpectSuccess(alice, collectionId, true);33    });34  });3536  it('ensure white-listed non-privileged address can mint tokens', async () => {37    await usingApi(async () => {38      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);39      await createItemExpectSuccess(bob, collectionId, 'NFT');40    });41  });42});4344describe('Negative Integration Test setMintPermission', () => {45  let alice: IKeyringPair;46  let bob: IKeyringPair;4748  before(async () => {49    await usingApi(async () => {50      alice = privateKey('//Alice');51      bob = privateKey('//Bob');52    });53  });5455  it('fails on not existing collection', async () => {56    await usingApi(async (api) => {57      const nonExistingCollection = await findNotExistingCollection(api);58      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);59    });60  });6162  it('fails on removed collection', async () => {63    await usingApi(async () => {64      const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });65      await destroyCollectionExpectSuccess(removedCollectionId);6667      await setMintPermissionExpectFailure(alice, removedCollectionId, true);68    });69  });7071  it('fails when not collection owner tries to set mint status', async () => {72    const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });73    await enableWhiteListExpectSuccess(alice, collectionId);74    await setMintPermissionExpectFailure(bob, collectionId, true);75  });76});
after · tests/src/setMintPermission.test.ts
1import { IKeyringPair } from '@polkadot/types/types';2import privateKey from './substrate/privateKey';3import usingApi from './substrate/substrate-api';4import {5  addToWhiteListExpectSuccess,6  createCollectionExpectSuccess,7  createItemExpectSuccess,8  destroyCollectionExpectSuccess,9  enableWhiteListExpectSuccess,10  findNotExistingCollection,11  setMintPermissionExpectFailure,12  setMintPermissionExpectSuccess,13} from './util/helpers';1415describe('Integration Test setMintPermission', () => {16  let alice: IKeyringPair;17  let bob: IKeyringPair;1819  before(async () => {20    await usingApi(async () => {21      alice = privateKey('//Alice');22      bob = privateKey('//Bob');23    });24  });2526  it('ensure white-listed non-privileged address can mint tokens', async () => {27    await usingApi(async () => {28      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });29      await enableWhiteListExpectSuccess(alice, collectionId);30      await setMintPermissionExpectSuccess(alice, collectionId, true);31      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);3233      await createItemExpectSuccess(bob, collectionId, 'NFT');34    });35  });36});3738describe('Negative Integration Test setMintPermission', () => {39  let alice: IKeyringPair;40  let bob: IKeyringPair;4142  before(async () => {43    await usingApi(async () => {44      alice = privateKey('//Alice');45      bob = privateKey('//Bob');46    });47  });4849  it('fails on not existing collection', async () => {50    await usingApi(async (api) => {51      const nonExistingCollection = await findNotExistingCollection(api);52      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);53    });54  });5556  it('fails on removed collection', async () => {57    await usingApi(async () => {58      const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });59      await destroyCollectionExpectSuccess(removedCollectionId);6061      await setMintPermissionExpectFailure(alice, removedCollectionId, true);62    });63  });6465  it('fails when not collection owner tries to set mint status', async () => {66    const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });67    await enableWhiteListExpectSuccess(alice, collectionId);68    await setMintPermissionExpectFailure(bob, collectionId, true);69  });70});