nucypher/taco-web

Add unit test for findParamWithAuthentication method in Condition class

开放

#695 创建于 2025年8月20日

 (1 条评论) (0 个反应) (0 位负责人)TypeScript (25 个派生)auto 404
good first issuetesting

仓库指标

星标
 (35 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Overview

The findParamWithAuthentication method in the Condition class has a TODO comment indicating it needs to be fixed and tested. Currently, there are no tests for this method.

Context

Located in packages/taco/src/conditions/condition.ts:42-49:

// TODO: Fix this method and add a test for it
public findParamWithAuthentication(): string | null {
  const serialized = toJSON(this.value);
  for (const param of USER_ADDRESS_PARAMS) {
    if (serialized.includes(param)) {
      return param;
    }
  }
  return null;
}

Tasks

  1. Understand what the method is supposed to do (find user address parameters in conditions)
  2. Write comprehensive unit tests covering:
    • Finding various USER_ADDRESS_PARAMS in conditions
    • Returning null when no params are found
    • Edge cases with nested conditions
  3. Fix any issues discovered during testing
  4. Remove the TODO comment once complete

Files to Change

  • Create new test cases in packages/taco/test/conditions/base/condition.test.ts or appropriate test file
  • Update packages/taco/src/conditions/condition.ts if fixes are needed

Test Cases to Include

  • Test with conditions containing :userAddress
  • Test with conditions containing :userAddressExternalWallet
  • Test with conditions containing no user address params
  • Test with nested/compound conditions
  • Test with multiple user address params (should return the first one found)

Definition of Done

  • Comprehensive test suite for findParamWithAuthentication
  • All tests passing
  • TODO comment removed
  • Method behavior documented if any fixes were needed

贡献者指南