All files / types/__testUtils__ testEnumMembers.ts

100% Statements 1/1
100% Branches 1/1
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                            6x          
import type IEnumMemberSymbol from "../symbols/IEnumMemberSymbol";
import TestMembers from "./testMembers";
 
/**
 * Builds the member map an `IEnumSymbol` carries, from a name-to-value object.
 *
 * Delegates to `TestMembers`, which owns what a member symbol's base half looks
 * like. This file used to hand-copy those nine fields (#1318 review), which is
 * the duplication `MemberSymbolBase` prevents on the production side leaking
 * back in on the mock side: a tenth field on `IBaseSymbol` meant editing two
 * places, and they would have drifted silently because a different set of tests
 * exercises each.
 *
 * Kept as a named entry point because `enum_member` is the one member kind with
 * a payload of its own (`value`), and call sites read better for it.
 */
class TestEnumMembers {
  static of(
    enumScopedName: string,
    values: Readonly<Record<string, number>>,
    sourceFile = "test.cnx",
  ): Map<string, IEnumMemberSymbol> {
    return TestMembers.asEnumMembers(enumScopedName, values, sourceFile);
  }
}
 
export default TestEnumMembers;