From cacafd7dca8f292770f29121355c04209238142c Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 10 Jan 2024 10:40:51 +0200 Subject: [PATCH] [docs] Fix parsing of `x-date-pickers-pro` demo adapter imports (#11628) --- .../modules/utils/postProcessImport.test.ts | 19 +++++++++++++++++++ docs/src/modules/utils/postProcessImport.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/src/modules/utils/postProcessImport.test.ts b/docs/src/modules/utils/postProcessImport.test.ts index d98af70876e07..b582e1df32d17 100644 --- a/docs/src/modules/utils/postProcessImport.test.ts +++ b/docs/src/modules/utils/postProcessImport.test.ts @@ -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], + }); + }); + }); + }); }); diff --git a/docs/src/modules/utils/postProcessImport.ts b/docs/src/modules/utils/postProcessImport.ts index 0177ae4f79a09..9418831f99302 100644 --- a/docs/src/modules/utils/postProcessImport.ts +++ b/docs/src/modules/utils/postProcessImport.ts @@ -18,7 +18,7 @@ export const ADAPTER_TO_LIBRARY: Record = { AdapterMomentJalaali: 'moment-jalaali', }; -const PICKERS_ADAPTER_REGEX = /^@mui\/(lab|x-date-pickers)\/(?Adapter.*)/; +const PICKERS_ADAPTER_REGEX = /^@mui\/(lab|x-date-pickers(?:-pro)?)\/(?Adapter.*)/; export const postProcessImport = (importName: string): Record | null => { // e.g. date-fns