File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change 1
1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
3
- exports [` definition for ' code-view' matches the snapshot 1` ] = `
3
+ exports [` definition for code-view matches the snapshot > code-view 1` ] = `
4
4
{
5
5
" dashCaseName" : " code-view" ,
6
6
" events" : [],
Original file line number Diff line number Diff line change 2
2
// SPDX-License-Identifier: Apache-2.0
3
3
import { expect , test } from "vitest" ;
4
4
5
- import apiDocs from "../../lib/components/internal/api-docs/components" ;
5
+ import componentDefinitions from "../../lib/components/internal/api-docs/components" ;
6
+ import { getAllComponents } from "./utils" ;
6
7
7
- test . each ( Object . entries ( apiDocs ) ) ( "definition for $0 matches the snapshot" , ( _name , definition ) => {
8
- expect ( definition ) . toMatchSnapshot ( ) ;
8
+ test . each < string > ( getAllComponents ( ) ) ( `definition for %s matches the snapshot` , ( componentName : string ) => {
9
+ const definition = componentDefinitions [ componentName ] ;
10
+ // overriding with a fake value so that when there are icon changes in components this test doesn't block it
11
+ const iconNameDefinition = definition . properties . find ( ( { name } : { name : string } ) => name === "iconName" ) ;
12
+ if ( iconNameDefinition && iconNameDefinition . inlineType ?. type === "union" ) {
13
+ iconNameDefinition . inlineType . values = [ "comes from @cloudscape-design/components" ] ;
14
+ }
15
+ expect ( definition ) . toMatchSnapshot ( componentName ) ;
9
16
} ) ;
Original file line number Diff line number Diff line change
1
+ /* eslint-env node */
2
+ /* eslint-disable header/header */
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ import * as fs from "node:fs" ;
6
+ import * as path from "node:path" ;
7
+
8
+ const componentsDir = path . resolve ( __dirname , "../../lib/components" ) ;
9
+
10
+ export function getAllComponents ( ) : string [ ] {
11
+ return fs
12
+ . readdirSync ( componentsDir )
13
+ . filter (
14
+ ( name ) =>
15
+ name !== "internal" &&
16
+ name !== "test-utils" &&
17
+ ! name . includes ( "." ) &&
18
+ ! name . includes ( "LICENSE" ) &&
19
+ ! name . includes ( "NOTICE" ) ,
20
+ ) ;
21
+ }
22
+
23
+ export async function requireComponent ( componentName : string ) {
24
+ // eslint-disable-next-line no-unsanitized/method
25
+ const { default : Component } = await import ( path . join ( componentsDir , componentName ) ) ;
26
+ return Component ;
27
+ }
You can’t perform that action at this time.
0 commit comments