git.delta.rocks / unique-network / refs/commits / 3c4a992556fd

difftreelog

feat add skip/only/ifWithPallets to itSub/itEth

Daniel Shiposha2022-09-22parent: #35dc5b5.patch.diff
in: master

2 files changed

modifiedtests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth
before · tests/src/eth/util/playgrounds/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56import config from '../../../config';78import {EthUniqueHelper} from './unique.dev';9import {SilentLogger, SilentConsole} from '../../../util/playgrounds/unique.dev';1011export {EthUniqueHelper} from './unique.dev';1213import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';15chai.use(chaiAsPromised);16export const expect = chai.expect;1718export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {19  const silentConsole = new SilentConsole();20  silentConsole.enable();2122  const helper = new EthUniqueHelper(new SilentLogger());2324  try {25    await helper.connect(config.substrateUrl);26    await helper.connectWeb3(config.substrateUrl);27    const ss58Format = helper.chain.getChainProperties().ss58Format;28    const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);29    await code(helper, privateKey);30  }31  finally {32    await helper.disconnect();33    await helper.disconnectWeb3();34    silentConsole.disable();35  }36};37  38export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {39  let i: any = it;40  if (opts.only) i = i.only;41  else if (opts.skip) i = i.skip;42  i(name, async () => {43    await usingEthPlaygrounds(async (helper, privateKey) => {44      await cb({helper, privateKey});45    });46  });47}48itEth.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});
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;