Skip to content

Commit

Permalink
fix(react): case sensitive file import with react app generator when … (
Browse files Browse the repository at this point in the history
  • Loading branch information
kaltepeter committed Apr 5, 2022
1 parent 14674a1 commit 274c050
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit 274c050

Please sign in to comment.