From b73dd1f3c56c1372588a39684d0c1374cefd1448 Mon Sep 17 00:00:00 2001 From: Twisted_Arrow Date: Tue, 1 Sep 2026 08:02:30 +0530 Subject: [PATCH] test(swift): cover valid prefix before later partial match --- .../scope-resolution/swift-target-grouping.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gitnexus/test/unit/scope-resolution/swift-target-grouping.test.ts b/gitnexus/test/unit/scope-resolution/swift-target-grouping.test.ts index 5b183ae47..f8e139968 100644 --- a/gitnexus/test/unit/scope-resolution/swift-target-grouping.test.ts +++ b/gitnexus/test/unit/scope-resolution/swift-target-grouping.test.ts @@ -12,6 +12,16 @@ describe('groupSwiftFilesBySpmTarget', () => { expect(groups.get('__default__')).toBeUndefined(); }); + it('keeps an earlier segment-aligned match when a later occurrence is partial', () => { + const targets = new Map([['Core', 'Modules/Core']]); + const items = ['Modules/Core/Thing/SubModules/Core/Thing.swift']; + + const groups = groupSwiftFilesBySpmTarget(items, (item) => item, targets); + + expect(groups.get('Core')).toEqual(items); + expect(groups.get('__default__')).toBeUndefined(); + }); + it('does not treat a partial path segment as a target match', () => { const targets = new Map([['Core', 'Modules/Core']]); const item = 'vendor/SubModules/Core/Thing.swift';