xref: /expo/apps/test-suite/tests/SVG.js (revision 22d1e005)
1import * as React from 'react';
2import * as Svg from 'react-native-svg';
3
4import { mountAndWaitFor as originalMountAndWaitFor } from './helpers';
5
6export const name = 'SVG';
7
8const components = [
9  'Circle',
10  'ClipPath',
11  'Defs',
12  'Ellipse',
13  'G',
14  'Image',
15  'Line',
16  'LinearGradient',
17  'Path',
18  'Pattern',
19  'Polygon',
20  'Polyline',
21  'RadialGradient',
22  'Rect',
23  'Stop',
24  'Svg',
25  'Symbol',
26  'TSpan',
27  'Text',
28  'TextPath',
29  'Use',
30  'Mask',
31];
32
33export function test(t, { setPortalChild, cleanupPortal }) {
34  const mountAndWaitFor = (child, propName = 'ref') =>
35    originalMountAndWaitFor(child, propName, setPortalChild);
36
37  t.describe(name, () => {
38    t.afterEach(async () => await cleanupPortal());
39
40    for (const component of components) {
41      t.it(component, async () => {
42        const SVGComponent = Svg[component];
43
44        await mountAndWaitFor(
45          <Svg.Svg key={`svg-${component}`}>
46            <SVGComponent />
47          </Svg.Svg>
48        );
49      });
50    }
51  });
52}
53