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