Skip to content

Commit

Permalink
[docs] Fix parsing of x-date-pickers-pro demo adapter imports (mui#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Jan 10, 2024
1 parent 0946a1b commit cacafd7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docs/src/modules/utils/postProcessImport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,23 @@ describe('postProcessImport', () => {
});
});
});

describe('@mui/x-date-pickers-pro imports', () => {
const ALL_ADAPTERS = [
...ADAPTERS,
'AdapterDateFnsJalali',
'AdapterMomentHijri',
'AdapterMomentJalaali',
];
ALL_ADAPTERS.forEach((adapter) => {
it('should provide correct adapter', () => {
const resolvedDep = postProcessImport(`@mui/x-date-pickers-pro/${adapter}`);

const expectedLibrary = ADAPTER_TO_LIBRARY[adapter];
expect(resolvedDep).to.deep.equal({
[expectedLibrary]: DATE_ADAPTER_VERSIONS[expectedLibrary],
});
});
});
});
});
2 changes: 1 addition & 1 deletion docs/src/modules/utils/postProcessImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ADAPTER_TO_LIBRARY: Record<string, string> = {
AdapterMomentJalaali: 'moment-jalaali',
};

const PICKERS_ADAPTER_REGEX = /^@mui\/(lab|x-date-pickers)\/(?<adapterName>Adapter.*)/;
const PICKERS_ADAPTER_REGEX = /^@mui\/(lab|x-date-pickers(?:-pro)?)\/(?<adapterName>Adapter.*)/;

export const postProcessImport = (importName: string): Record<string, string> | null => {
// e.g. date-fns
Expand Down

0 comments on commit cacafd7

Please sign in to comment.