git.delta.rocks / unique-network / refs/commits / 644729ef9420

difftreelog

Merge pull request #605 from UniqueNetwork/feature/playgrounds-it-improve

ut-akuznetsov2022-09-22parents: #35dc5b5 #3c4a992.patch.diff
in: master

2 files changed

modifiedtests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth
1212
13import chai from 'chai';13import chai from 'chai';
14import chaiAsPromised from 'chai-as-promised';14import chaiAsPromised from 'chai-as-promised';
15import { requirePalletsOrSkip } from '../../../util/playgrounds';
15chai.use(chaiAsPromised);16chai.use(chaiAsPromised);
16export const expect = chai.expect;17export const expect = chai.expect;
1718
35 }36 }
36};37};
37 38
38export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {39export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
39 let i: any = it;40 (opts.only ? it.only :
40 if (opts.only) i = i.only;
41 else if (opts.skip) i = i.skip;
42 i(name, async () => {41 opts.skip ? it.skip : it)(name, async function() {
43 await usingEthPlaygrounds(async (helper, privateKey) => {42 await usingEthPlaygrounds(async (helper, privateKey) => {
43 if (opts.requiredPallets) {
44 requirePalletsOrSkip(this, helper, opts.requiredPallets);
45 }
46
44 await cb({helper, privateKey});47 await cb({helper, privateKey});
45 });48 });
46 });49 });
47}50}
51
52export async function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
53 return itEth(name, cb, {requiredPallets: required, ...opts});
54}
55
48itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {only: true});56itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {only: true});
49itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {skip: true});57itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {skip: true});
58
59itEthIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEthIfWithPallet(name, required, cb, {only: true});
60itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});
61itEth.ifWithPallets = itEthIfWithPallet;
62
modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/index.ts
+++ b/tests/src/util/playgrounds/index.ts
@@ -63,6 +63,12 @@
     });
   });
 }
+export async function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+  return itSub(name, cb, {requiredPallets: required, ...opts});
+}
 itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSub(name, cb, {only: true});
 itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSub(name, cb, {skip: true});
-itSub.ifWithPallets = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSub(name, cb, {requiredPallets: required});
+
+itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSubIfWithPallet(name, required, cb, {only: true});
+itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});
+itSub.ifWithPallets = itSubIfWithPallet;