diff --git a/packages/taco/test/conditions/base/rpc.test.ts b/packages/taco/test/conditions/base/rpc.test.ts index 4a86d5ba9..95450eefd 100644 --- a/packages/taco/test/conditions/base/rpc.test.ts +++ b/packages/taco/test/conditions/base/rpc.test.ts @@ -98,7 +98,7 @@ describe('validation', () => { it('rejects empty parameters', () => { const rpcObj = { ...testRpcConditionObj, - parameters: [], + parameters: [], // Update this after updating available RPC methods }; const result = RpcCondition.validate(rpcConditionSchema, rpcObj); diff --git a/packages/taco/test/conditions/compound-condition.test.ts b/packages/taco/test/conditions/compound-condition.test.ts index 4c8b7d0c2..8df2327e8 100644 --- a/packages/taco/test/conditions/compound-condition.test.ts +++ b/packages/taco/test/conditions/compound-condition.test.ts @@ -7,8 +7,8 @@ import { TimeCondition, } from '../../src/conditions'; import { - compoundConditionSchema, CompoundConditionType, + compoundConditionSchema, } from '../../src/conditions/compound-condition'; import { testContractConditionObj, @@ -225,27 +225,58 @@ describe('validation', () => { expect(() => new CompoundCondition(badObj)).toThrow(); }); - it('rejects empty operands', () => { - const badObj = { - operator: 'and', - operands: [], - }; - expect(() => new CompoundCondition(badObj)).toThrow(); - }); + it.each(['or', 'and'])( + 'rejects empty operands for "%s" operator', + (operator) => { + const badObj = { + operator, + operands: [], + }; + expect(() => new CompoundCondition(badObj)).toThrow(); + }, + ); - it('rejects non-array operands for "and" and "or" operators', () => { - const badObj = { - operator: 'and', - operands: testContractConditionObj, - }; - expect(() => new CompoundCondition(badObj)).toThrow(); - }); + it.each(['or', 'and'])( + 'rejects non-array operands for "%s" operator', + (operator) => { + const badObj = { + operator, + operands: testContractConditionObj, + }; + expect(() => new CompoundCondition(badObj)).toThrow(); + }, + ); - it('rejects array operands for "not" operator', () => { + it('rejects array operands with non-one length for "not" operator', () => { const badObj = { operator: 'not', operands: [testContractConditionObj, testTimeConditionObj], }; expect(() => new CompoundCondition(badObj)).toThrow(); }); + + it.each(['or', 'and'])( + 'accepts array operands for "%s" operator', + (operator) => { + const obj = { + operator, + operands: [testContractConditionObj, testTimeConditionObj], + }; + expect(new CompoundCondition(obj).toObj()).toEqual({ + conditionType: CompoundConditionType, + ...obj, + }); + }, + ); + + it.each(['or', 'and'])( + 'rejects array operands with non-greater-than-one length for "%s" operator', + (operator) => { + const badObj = { + operator, + operands: [testContractConditionObj], + }; + expect(() => new CompoundCondition(badObj)).toThrow(); + }, + ); }); diff --git a/packages/taco/test/conditions/context.test.ts b/packages/taco/test/conditions/context.test.ts index f76763d47..64529fc76 100644 --- a/packages/taco/test/conditions/context.test.ts +++ b/packages/taco/test/conditions/context.test.ts @@ -261,10 +261,6 @@ describe('param or context param schema', () => { expect(paramOrContextParamSchema.safeParse(123.4).success).toBe(true); }); - it('accepts a hex string', () => { - expect(paramOrContextParamSchema.safeParse('deadbeef').success).toBe(true); - }); - it('accepts a 0x-prefixed hex string', () => { expect(paramOrContextParamSchema.safeParse('0xdeadbeef').success).toBe( true, diff --git a/packages/taco/test/test-utils.ts b/packages/taco/test/test-utils.ts index 024197bd2..50d97a074 100644 --- a/packages/taco/test/test-utils.ts +++ b/packages/taco/test/test-utils.ts @@ -26,11 +26,11 @@ import { zip, } from '@nucypher/shared'; import { + TEST_CHAIN_ID, + TEST_CONTRACT_ADDR, fakeDkgFlow, fakeSigner, fakeTDecFlow, - TEST_CHAIN_ID, - TEST_CONTRACT_ADDR, } from '@nucypher/test-utils'; import { SpyInstance, vi } from 'vitest';