Skip to content

Commit

Permalink
chore: add .only and .skip variations for compliance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Feb 9, 2024
1 parent 6cda923 commit 6fa4bec
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/0.8.9/stakingRouter/stakingRouter.versioned.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StakingRouter__factory } from "typechain-types";

import { randomAddress } from "lib";

import testVersionedCompliance from "../../common/versioned.test";
import { testVersionedCompliance } from "../../common/versioned.test";

testVersionedCompliance({
name: "StakingRouter",
Expand Down
17 changes: 12 additions & 5 deletions test/common/erc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ interface ERC20Target {
* @param {object} target.deploy async function that returns the instance of the contract and initial parameters
* @param {object} target.suiteFunction function that runs the suite, a temporary workaround for running
* the suite exclusively or skipping the suite; see the todo below
*
* @todo rewrite the function to support the same interface as `describe`, i.e.
* instead of passing `suiteFunction`, we should be able to call the function like:
* testERC20Compliance.only(target)
* testERC20Compliance.skip(target)
*/
export function testERC20Compliance({ tokenName, deploy, suiteFunction = describe }: ERC20Target) {
suiteFunction(`${tokenName} ERC-20 Compliance`, () => {
Expand Down Expand Up @@ -306,3 +301,15 @@ export function testERC20Compliance({ tokenName, deploy, suiteFunction = describ
});
});
}

testERC20Compliance.only = (target: ERC20Target) =>
testERC20Compliance({
...target,
suiteFunction: describe.only, // eslint-disable-line no-only-tests/no-only-tests
});

testERC20Compliance.skip = (target: ERC20Target) =>
testERC20Compliance({
...target,
suiteFunction: describe.skip,
});
16 changes: 12 additions & 4 deletions test/common/erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ interface ERC721Target {
*
* @todo call safeTransferFrom directly instead of using signature
* @todo use DRY when testing overloadable functions (calling without and with extra data)
* @todo rewrite the function to support the same interface as `describe`, i.e.
* instead of passing `suiteFunction`, we should be able to call the function like:
* testERC20Compliance.only(target)
* testERC20Compliance.skip(target)
*/
export function testERC721Compliance({ tokenName, deploy, suiteFunction = describe }: ERC721Target) {
suiteFunction(`${tokenName} ERC-721 Compliance`, () => {
Expand Down Expand Up @@ -400,3 +396,15 @@ export function testERC721Compliance({ tokenName, deploy, suiteFunction = descri
});
});
}

testERC721Compliance.only = (target: ERC721Target) =>
testERC721Compliance({
...target,
suiteFunction: describe.only, // eslint-disable-line no-only-tests/no-only-tests
});

testERC721Compliance.skip = (target: ERC721Target) =>
testERC721Compliance({
...target,
suiteFunction: describe.skip,
});
19 changes: 13 additions & 6 deletions test/common/versioned.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ interface VersionedTarget {
* predict how the derived contracts are used.
* @param {object} target.suiteFunction function that runs the suite, a temporary workaround for running
* the suite exclusively or skipping the suite; see the todo below
*
* @todo rewrite the function to support the same interface as `describe`, i.e.
* instead of passing `suiteFunction`, we should be able to call the function like:
* testVersionedCompliance.only(target)
* testVersionedCompliance.skip(target)
*/
export default function testVersionedCompliance({ name, deploy, updates, suiteFunction = describe }: VersionedTarget) {
export function testVersionedCompliance({ name, deploy, updates, suiteFunction = describe }: VersionedTarget) {
suiteFunction(`${name} Versioned Compliance`, () => {
let admin: HardhatEthersSigner;
let user: HardhatEthersSigner;
Expand Down Expand Up @@ -90,3 +85,15 @@ export default function testVersionedCompliance({ name, deploy, updates, suiteFu
});
});
}

testVersionedCompliance.only = (target: VersionedTarget) =>
testVersionedCompliance({
...target,
suiteFunction: describe.only, // eslint-disable-line no-only-tests/no-only-tests
});

testVersionedCompliance.skip = (target: VersionedTarget) =>
testVersionedCompliance({
...target,
suiteFunction: describe.skip,
});

0 comments on commit 6fa4bec

Please sign in to comment.