Skip to content

Commit

Permalink
Add tests for processing addition of authProviders to ConditionContext.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre committed Jul 23, 2024
1 parent 9acd772 commit 75e7a63
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/taco/test/conditions/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,62 @@ describe('No authentication provider', () => {
});
});

it('rejects auth provider for not applicable context param', () => {
const conditionObj = {
...testContractConditionObj,
returnValueTest: {
...testReturnValueTest,
value: ':myParam',
},
};
const condition = new ContractCondition(conditionObj);
const conditionContext = new ConditionContext(condition);
expect(() =>
conditionContext.addAuthProvider(
':myParam',
authProviders[USER_ADDRESS_PARAM_DEFAULT],
),
).toThrow('AuthProvider not necessary for context parameter: :myParam');
});

it('rejects invalid auth provider for :userAddress', () => {
const conditionObj = {
...testContractConditionObj,
returnValueTest: {
...testReturnValueTest,
value: USER_ADDRESS_PARAM_DEFAULT,
},
};
const condition = new ContractCondition(conditionObj);
const conditionContext = new ConditionContext(condition);
expect(() =>
conditionContext.addAuthProvider(
USER_ADDRESS_PARAM_DEFAULT,
authProviders[USER_ADDRESS_PARAM_EXTERNAL_EIP4361],
),
).toThrow(`Invalid AuthProvider type for ${USER_ADDRESS_PARAM_DEFAULT}`);
});

it('rejects invalid auth provider for :userAddressExternalEIP4361', () => {
const conditionObj = {
...testContractConditionObj,
returnValueTest: {
...testReturnValueTest,
value: USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
},
};
const condition = new ContractCondition(conditionObj);
const conditionContext = new ConditionContext(condition);
expect(() =>
conditionContext.addAuthProvider(
USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
authProviders[USER_ADDRESS_PARAM_DEFAULT],
),
).toThrow(
`Invalid AuthProvider type for ${USER_ADDRESS_PARAM_EXTERNAL_EIP4361}`,
);
});

it('it supports just one provider at a time', async () => {
const conditionObj = {
...testContractConditionObj,
Expand Down

0 comments on commit 75e7a63

Please sign in to comment.