diff --git a/src/__tests__/host-component-names.test.tsx b/src/__tests__/host-component-names.test.tsx index 3fbf5fdf2..8e2532412 100644 --- a/src/__tests__/host-component-names.test.tsx +++ b/src/__tests__/host-component-names.test.tsx @@ -38,6 +38,13 @@ test('detects host Switch component', async () => { expect(isHostSwitch(screen.root)).toBe(true); }); +// The iOS native component spec codegens under the name `Switch`, so the bare +// name has to be recognised alongside the legacy `RCTSwitch` one. +test('detects raw Switch component', async () => { + await render(React.createElement('Switch', { testID: 'switch' })); + expect(isHostSwitch(screen.root)).toBe(true); +}); + test('detects host ScrollView component', async () => { await render(); expect(isHostScrollView(screen.root)).toBe(true); diff --git a/src/helpers/host-component-names.ts b/src/helpers/host-component-names.ts index 2b7f59860..48ee21a41 100644 --- a/src/helpers/host-component-names.ts +++ b/src/helpers/host-component-names.ts @@ -3,7 +3,7 @@ import type { TestInstance } from 'test-renderer'; export const HOST_TEXT_NAMES = ['Text', 'RCTText']; const HOST_TEXT_INPUT_NAMES = ['TextInput']; const HOST_IMAGE_NAMES = ['Image']; -const HOST_SWITCH_NAMES = ['RCTSwitch']; +const HOST_SWITCH_NAMES = ['Switch', 'RCTSwitch']; const HOST_SCROLL_VIEW_NAMES = ['RCTScrollView']; const HOST_MODAL_NAMES = ['Modal'];