1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import { default as usingApi } from './substrate/substrate-api';4import {5 createCollectionExpectSuccess,6 destroyCollectionExpectSuccess,7 enableWhiteListExpectSuccess,8 addToWhiteListExpectSuccess,9 removeFromWhiteListExpectSuccess,10 isWhitelisted,11 findNotExistingCollection,12 removeFromWhiteListExpectFailure,13 disableWhiteListExpectSuccess,14} from './util/helpers';15import { IKeyringPair } from '@polkadot/types/types';16import privateKey from './substrate/privateKey';1718chai.use(chaiAsPromised);19const expect = chai.expect;2021describe('Integration Test removeFromWhiteList', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;24 let collectionId: number;2526 before(async () => {27 await usingApi(async (api) => {28 alice = privateKey('//Alice');29 bob = privateKey('//Bob');30 collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });31 await enableWhiteListExpectSuccess(alice, collectionId);32 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);33 });34 });3536 it('remove bob from whitelist', async () => {37 await usingApi(async () => {38 await removeFromWhiteListExpectSuccess(alice, collectionId, bob.address);39 });40 });4142 it('ensure bob is no longer in whitelist', async () => {43 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;44 });4546 it('allows removal from collection with unset whitelist status', async () => {47 await usingApi(async () => {48 const collectionWithoutWhitelistId = await createCollectionExpectSuccess();49 await enableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);50 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);51 await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);5253 await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);54 });55 });56});5758describe('Negative Integration Test removeFromWhiteList', () => {59 let alice: IKeyringPair;60 let bob: IKeyringPair;6162 before(async () => {63 await usingApi(async (api) => {64 alice = privateKey('//Alice');65 bob = privateKey('//Bob');66 });67 });6869 it('fails on removal from not existing collection', async () => {70 await usingApi(async (api) => {71 const collectionId = await findNotExistingCollection(api);7273 await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);74 });75 });7677 it('fails on removal from removed collection', async () => {78 await usingApi(async () => {79 const collectionId = await createCollectionExpectSuccess();80 await enableWhiteListExpectSuccess(alice, collectionId);81 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);82 await destroyCollectionExpectSuccess(collectionId);8384 await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);85 });86 });87});