Skip to content

Commit

Permalink
refactor(contract): use describe.each for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Oct 20, 2020
1 parent 83bcd89 commit 2c7ced7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/account.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions test/contract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ describe('viewMethod', () => {
expect(stubbedReturnValue.options.parse).toBe(customParser);
});

test('throws PositionalArgsError if second argument is not an object', () => {
return Promise.all([
1,
'lol',
[],
new Date(),
null,
new Set(),
].map(async badArgs => {
describe.each([
1,
'lol',
[],
new Date(),
null,
new Set(),
])('throws PositionalArgsError if 2nd arg is not an object', badArg => {
test(String(badArg), async () => {
try {
await contract.viewMethod({ a: 1 }, badArgs);
throw new Error(`Calling \`contract.viewMethod({ a: 1 }, ${badArgs})\` worked. It shouldn't have worked.`);
await contract.viewMethod({ a: 1 }, badArg);
throw new Error(`Calling \`contract.viewMethod({ a: 1 }, ${badArg})\` worked. It shouldn't have worked.`);
} catch (e) {
if (!(e instanceof PositionalArgsError)) throw e;
}
}));
});
});
});

Expand Down

0 comments on commit 2c7ced7

Please sign in to comment.