git.delta.rocks / unique-network / refs/commits / 104a9a3f8121

difftreelog

Merge pull request #78 from usetech-llc/feature/NFTPAR-247_removeFromWhiteList

Greg Zaitsev2021-02-03parents: #3f3b2f7 #70ccc05.patch.diff
in: master
Add tests for removeFromWhiteList

3 files changed

modifiedtests/package.jsondiffbeforeafterboth
25 "testSetVariableMetaData": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetaData.test.ts",25 "testSetVariableMetaData": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetaData.test.ts",
26 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",26 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",
27 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",27 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",
28 "testRemoveFromWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromWhiteList.test.ts",
28 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",29 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
29 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",30 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
30 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",31 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",
addedtests/src/removeFromWhiteList.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
645 return newItemId;645 return newItemId;
646}646}
647647
648export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {648export async function setPublicAccessModeExpectSuccess(
649 sender: IKeyringPair, collectionId: number,
650 accessMode: 'Normal' | 'WhiteList',
651) {
649 await usingApi(async (api) => {652 await usingApi(async (api) => {
650653
651 // Run the transaction654 // Run the transaction
652 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');655 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);
653 const events = await submitTransactionAsync(sender, tx);656 const events = await submitTransactionAsync(sender, tx);
654 const result = getGenericResult(events);657 const result = getGenericResult(events);
655658
659 // What to expect662 // What to expect
660 // tslint:disable-next-line:no-unused-expression663 // tslint:disable-next-line:no-unused-expression
661 expect(result.success).to.be.true;664 expect(result.success).to.be.true;
662 expect(collection.Access).to.be.equal('WhiteList');665 expect(collection.Access).to.be.equal(accessMode);
663 });666 });
664}667}
668
669export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {
670 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');
671}
672
673export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {
674 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');
675}
665676
666export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {677export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {
667 await usingApi(async (api) => {678 await usingApi(async (api) => {
680 });691 });
681}692}
693
694export async function isWhitelisted(collectionId: number, address: string) {
695 let whitelisted: boolean = false;
696 await usingApi(async (api) => {
697 whitelisted = (await api.query.nft.whiteList(collectionId, address)).toJSON() as unknown as boolean;
698 });
699 return whitelisted;
700}
682701
683export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {702export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {
684 await usingApi(async (api) => {703 await usingApi(async (api) => {
702 });721 });
703}722}
723
724export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {
725 await usingApi(async (api) => {
726 // Run the transaction
727 const tx = api.tx.nft.removeFromWhiteList(collectionId, address);
728 const events = await submitTransactionAsync(sender, tx);
729 const result = getGenericResult(events);
730
731 // What to expect
732 // tslint:disable-next-line:no-unused-expression
733 expect(result.success).to.be.true;
734 });
735}
736
737export async function removeFromWhiteListExpectFailure(sender: IKeyringPair, collectionId: number, address: string) {
738 await usingApi(async (api) => {
739 // Run the transaction
740 const tx = api.tx.nft.removeFromWhiteList(collectionId, address);
741 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
742 const result = getGenericResult(events);
743
744 // What to expect
745 // tslint:disable-next-line:no-unused-expression
746 expect(result.success).to.be.false;
747 });
748}
704749
705export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)750export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)
706 : Promise<ICollectionInterface | null> => {751 : Promise<ICollectionInterface | null> => {