From 274c050fc9e92955038d7e1943562867b465d869 Mon Sep 17 00:00:00 2001 From: Kayla Altepeter Date: Tue, 5 Apr 2022 09:25:52 -0500 Subject: [PATCH] =?UTF-8?q?fix(react):=20case=20sensitive=20file=20import?= =?UTF-8?q?=20with=20react=20app=20generator=20when=20=E2=80=A6=20(#9670)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/application.spec.ts | 20 +++++++++++++++++++ .../src/app/__fileName__.spec.tsx__tmpl__ | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index d03f3d4f2279e..beab116c056a7 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -399,6 +399,16 @@ Object { expect(appTree.exists('apps/my-app/src/app/App.spec.tsx')).toBeTruthy(); expect(appTree.exists('apps/my-app/src/app/App.module.css')).toBeTruthy(); }); + + it(`should use the correct case for file import in the spec file`, async () => { + await applicationGenerator(appTree, { ...schema, pascalCaseFiles: true }); + + const appSpecContent = appTree + .read('apps/my-app/src/app/App.spec.tsx') + .toString(); + + expect(appSpecContent).toMatch(/import App from '.\/App'/); + }); }); it('should generate functional components by default', async () => { @@ -409,6 +419,16 @@ Object { expect(appContent).not.toMatch(/extends Component/); }); + it(`should use the correct case for file import in the spec file`, async () => { + await applicationGenerator(appTree, { ...schema }); + + const appSpecContent = appTree + .read('apps/my-app/src/app/app.spec.tsx') + .toString(); + + expect(appSpecContent).toMatch(/import App from '.\/app'/); + }); + it('should add .eslintrc.json and dependencies', async () => { await applicationGenerator(appTree, { ...schema, linter: Linter.EsLint }); diff --git a/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ b/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ index cb810d67d8c66..86f0708d4445b 100644 --- a/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ +++ b/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ @@ -3,7 +3,7 @@ import { render } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; <% } %> -import App from './app'; +import App from './<%= fileName %>'; describe('App', () => { it('should render successfully', () => {