Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export default {
{
...tsConfig,
diagnostics: {
ignoreCodes: [1343]
// See codes https://github.com/Microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json
// 1324 - Dynamic imports only support a second argument when the '--module' option is...
// 1343 - The 'import.meta' meta-property is only allowed when the '--module' option is...
ignoreCodes: [1324, 1343]
},
astTransformers: {
before: [
Expand Down
12 changes: 11 additions & 1 deletion src/__tests__/__snapshots__/options.defaults.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,18 @@ exports[`options defaults should return specific properties: defaults 1`] = `
"availableResourceVersions": [
"6.0.0",
],
"availableSchemasVersions": [
"v6",
],
"availableSearchVersions": [
"current",
"latest",
"v6",
],
"default": {
"defaultVersion": "6.0.0",
"latestSchemasVersion": "v6",
"latestSemVer": "6.0.0",
"latestVersion": "v6",
"versionStrategy": "highest",
"versionWhitelist": [
"@patternfly/react-core",
Expand Down
49 changes: 49 additions & 0 deletions src/__tests__/__snapshots__/patternFly.getResources.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`getPatternFlyMcpResources should return multiple organized facets: properties 1`] = `
[
"availableSemVer",
"availableVersions",
"availableSchemasVersions",
"enumeratedVersions",
"envSemVer",
"envVersion",
"latestVersion",
"latestSchemasVersion",
"isEnvTheLatestVersion",
"isEnvTheLatestSchemasVersion",
"resources",
"docsIndex",
"componentsIndex",
"keywordsIndex",
"isFallbackDocumentation",
"pathIndex",
"byPath",
"byUri",
"byVersion",
"byVersionComponentNames",
]
`;

exports[`getPatternFlyReactComponentNames should return multiple organized facets: properties 1`] = `
[
"byVersion",
"componentNamesIndex",
"componentNamesWithSchemasIndex",
"componentNamesWithSchemasMap",
]
`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, accessibility 1`] = `"Accessibility"`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, design 1`] = `"Design Guidelines"`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, empty string 1`] = `"Documentation"`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, example 1`] = `"Examples"`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, guidelines 1`] = `"AI Guidance"`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, null 1`] = `"Documentation"`;

exports[`setCategoryDisplayLabel should normalize categories and apply linking markdown, undefined 1`] = `"Documentation"`;
100 changes: 100 additions & 0 deletions src/__tests__/__snapshots__/patternFly.helpers.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, current 1`] = `
[
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, detected 1`] = `
[
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, empty 1`] = `
[
"current",
"latest",
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, exact semver 1`] = `
[
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, latest 1`] = `
[
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, null 1`] = `
[
"current",
"latest",
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, semver 1`] = `
[
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, tag 1`] = `
[
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, unavailable exact semver 1`] = `
[
"current",
"latest",
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, unavailable semver 1`] = `
[
"current",
"latest",
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, unavailable tag 1`] = `
[
"current",
"latest",
"v6",
]
`;

exports[`filterEnumeratedPatternFlyVersions should attempt to refine a PatternFly versions based on available enumerations, undefined 1`] = `
[
"current",
"latest",
"v6",
]
`;

exports[`getPatternFlyVersionContext should temporarily return option.defaults and latest versions with specific properties: keys 1`] = `
[
"availableSemVer",
"availableVersions",
"availableSchemasVersions",
"enumeratedVersions",
"envSemVer",
"envVersion",
"latestVersion",
"latestSchemasVersion",
"isEnvTheLatestVersion",
"isEnvTheLatestSchemasVersion",
]
`;
25 changes: 25 additions & 0 deletions src/__tests__/__snapshots__/patternFly.search.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`searchPatternFly should attempt to return an array of all available results, all search: keys 1`] = `
[
"isSearchWildCardAll",
"firstExactMatch",
"exactMatches",
]
`;

exports[`searchPatternFly should attempt to return an array of all available results, empty all search: keys 1`] = `
[
"isSearchWildCardAll",
"firstExactMatch",
"exactMatches",
]
`;

exports[`searchPatternFly should attempt to return an array of all available results, wildcard search: keys 1`] = `
[
"isSearchWildCardAll",
"firstExactMatch",
"exactMatches",
]
`;
109 changes: 109 additions & 0 deletions src/__tests__/patternFly.getResources.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import {
setCategoryDisplayLabel,
getPatternFlyComponentSchema,
getPatternFlyReactComponentNames,
getPatternFlyMcpResources
} from '../patternFly.getResources';

describe('setCategoryDisplayLabel', () => {
it.each([
{
description: 'empty string',
entry: ''
},
{
description: 'undefined',
entry: undefined
},
{
description: 'null',
entry: null
},
{
description: 'design',
entry: {
displayName: 'Lorem Ipsum',
section: 'components',
category: 'design-guidelines',
path: 'https://www.patternfly.org/v6/components/lorem-ipsum/design-guidelines'
}
},
{
description: 'accessibility',
entry: {
displayName: 'Dolor Sit',
section: 'components',
category: 'accessibility',
path: 'https://www.patternfly.org/v6/components/dolor-sit/accessibility'
}
},
{
description: 'example',
entry: {
displayName: 'Lorem Sit',
section: 'components',
category: 'react',
path: 'https://www.patternfly.org/v6/components/lorem-sit/components'
}
},
{
description: 'guidelines',
entry:
{
displayName: 'Sit Sit',
section: 'guidelines',
category: 'react',
path: 'documentation:components/sit-sit/guidelines.md'
}
}
])('should normalize categories and apply linking markdown, $description', ({ entry }) => {
expect(setCategoryDisplayLabel(entry as any)).toMatchSnapshot();
});
});

describe('getPatternFlyComponentSchema', () => {
it.each([
{
description: 'default',
componentName: 'Button',
expected: true
},
{
description: 'unknown component',
componentName: 'Lorem',
expected: false
}
])('should attempt to return a schema', async ({ componentName, expected }) => {
const output = await getPatternFlyComponentSchema(componentName);

expect(Boolean(output)).toBe(expected);
});

it('should have a memoized property', () => {
expect(getPatternFlyComponentSchema).toHaveProperty('memo');
});
});

describe('getPatternFlyReactComponentNames', () => {
it('should return multiple organized facets', async () => {
const result = await getPatternFlyReactComponentNames();

expect(Object.keys(result)).toMatchSnapshot('properties');
});

it('should have a memoized property', () => {
expect(getPatternFlyReactComponentNames).toHaveProperty('memo');
});
});

describe('getPatternFlyMcpResources', () => {
it('should return multiple organized facets', async () => {
const result = await getPatternFlyMcpResources();

expect(Object.keys(result)).toMatchSnapshot('properties');
});

it('should have a memoized property', async () => {
expect(getPatternFlyMcpResources).toHaveProperty('memo');
});
});
Loading
Loading