Skip to content

Commit d49c4a6

Browse files
committed
test(gates): pin the fixture-host guard to the host's single class lookup
The host app resolves exactly one class by name, so the guard asserts one NSClassFromString rather than parsing the method body: a second lookup fails the guard instead of steering it to the wrong class.
1 parent fc63b1e commit d49c4a6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎scripts/__tests__/runner-fixture-host-lookup.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ const fixturesSource = path.join(
2222

2323
test('the host app looks up a fixture class the fixtures file declares', () => {
2424
const host = fs.readFileSync(hostSource, 'utf8');
25-
const lookup = host.match(/NSClassFromString\(@"(\w+)"\)/);
26-
assert.ok(lookup, 'the host app must resolve the fixture host with NSClassFromString');
27-
const className = lookup[1]!;
25+
// The host app resolves exactly one class by name: the fixture host in
26+
// +agentDeviceRootViewControllerClass. Asserting the single occurrence keeps this guard from
27+
// silently validating a different lookup if another NSClassFromString is ever added.
28+
const lookups = [...host.matchAll(/NSClassFromString\(@"(\w+)"\)/g)];
29+
assert.equal(lookups.length, 1, 'the host app must hold exactly one NSClassFromString lookup');
30+
const className = lookups[0]![1]!;
31+
assert.match(host, /\+ \(Class\)agentDeviceRootViewControllerClass/);
2832
const fixtures = fs.readFileSync(fixturesSource, 'utf8');
2933
// The class the host names must be declared and implemented by the fixtures file.
3034
assert.match(fixtures, new RegExp(`@interface ${className} :`));

0 commit comments

Comments
 (0)