');
});
it('hasChild with deep:true matches descendants', async () => {
const source = `function App(){ return
; }`;
const { code } = await compileReact(source, {
transforms: [
replace({
match: byTag('A', { when: hasChild(byTag('B'), { deep: true }) }),
with: { source: 'p', name: 'Z' },
}),
],
});
expect(code).toContain('
');
});
it('hasChild composes with byTag for nested shape checks', async () => {
const source = `function App(){
return <>>;
}`;
const { code } = await compileReact(source, {
transforms: [
replace({
match: byTag('Outer', { when: hasChild(byTag('Inner', { when: hasChild(byTag('Target')) })) }),
with: { source: 'p', name: 'Matched' },
}),
],
});
// Only the Outer with Inner→Target gets replaced.
expect(code).toContain('');
expect(code).toContain('