Skip to content

Commit b2e38c9

Browse files
committed
remove svg condition and add unit test
1 parent 92fb204 commit b2e38c9

File tree

5 files changed

+79
-2
lines changed

5 files changed

+79
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import * as React from 'react';
5+
import { NonCancelableEventHandler } from '../../internal/events';
6+
7+
namespace Highcharts {
8+
export interface Point {
9+
x: number;
10+
y: number;
11+
}
12+
}
13+
14+
export interface ChartProps {
15+
onHighlight?: NonCancelableEventHandler<{ point: Highcharts.Point }>;
16+
}
17+
18+
/**
19+
* Chart description
20+
*/
21+
export default function Chart({ onHighlight }: ChartProps) {
22+
return (
23+
<svg>
24+
<div onMouseOver={() => onHighlight?.({ detail: { point: { x: 0, y: 0 } } })}></div>
25+
</svg>
26+
);
27+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["./**/*.tsx"]
4+
}

src/components/object-definition.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export function getObjectDefinition(
2727
realType.flags & ts.TypeFlags.Number ||
2828
isArrayType(realType) ||
2929
realTypeName === 'HTMLElement' ||
30-
realTypeName.startsWith('SVG') ||
31-
realTypeName.includes('Highcharts') ||
30+
realTypeName === 'Highcharts.Point' ||
3231
type === 'React.ReactNode'
3332
) {
3433
// do not expand built-in Javascript methods or primitive values
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`should not expand highcharts types 1`] = `
4+
[
5+
{
6+
"dashCaseName": "chart",
7+
"description": "Chart description",
8+
"events": [
9+
{
10+
"cancelable": false,
11+
"deprecatedTag": undefined,
12+
"description": undefined,
13+
"detailInlineType": {
14+
"name": "{ point: Highcharts.Point; }",
15+
"properties": [
16+
{
17+
"name": "point",
18+
"optional": false,
19+
"type": "Highcharts.Point",
20+
},
21+
],
22+
"type": "object",
23+
},
24+
"detailType": "{ point: Highcharts.Point; }",
25+
"name": "onHighlight",
26+
"systemTags": undefined,
27+
},
28+
],
29+
"functions": [],
30+
"name": "Chart",
31+
"properties": [],
32+
"regions": [],
33+
"releaseStatus": "stable",
34+
"systemTags": undefined,
35+
},
36+
]
37+
`;

test/components/highcharts.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { expect, test } from 'vitest';
5+
import { buildProject } from './test-helpers';
6+
7+
test('should not expand highcharts types', () => {
8+
const result = buildProject('highcharts');
9+
expect(result).toMatchSnapshot();
10+
});

0 commit comments

Comments
 (0)