Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): case sensitive file import with react app generator when … #9670

Merged
merged 2 commits into from Apr 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/react/src/generators/application/application.spec.ts
Expand Up @@ -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 () => {
Expand All @@ -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 });

Expand Down
Expand Up @@ -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', () => {
Expand Down