Skip to content

Commit

Permalink
Merge pull request #3350 from hdurix/clean-styled
Browse files Browse the repository at this point in the history
Remove no style APIs old stuff
  • Loading branch information
DamnClin authored Aug 31, 2022
2 parents 7f26255 + 617c17c commit 5ca8532
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ReactCoreApplicationService() {
factory = new ReactCoreModulesFactory();
}

public JHipsterModule buildModuleWithStyle(JHipsterModuleProperties properties) {
return factory.buildModuleWithStyle(properties);
public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return factory.buildModule(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ReactCoreModulesFactory {

private static final String TEST_PRIMARY = "src/test/javascript/spec/common/primary/app";

public JHipsterModule buildModuleWithStyle(JHipsterModuleProperties properties) {
public JHipsterModule buildModule(JHipsterModuleProperties properties) {
//@formatter:off
return ClientsModulesFactory.clientModuleBuilder(properties)
.packageJson()
Expand Down Expand Up @@ -71,7 +71,7 @@ public JHipsterModule buildModuleWithStyle(JHipsterModuleProperties properties)
.add(WEBAPP_SOURCE.template("index.html"), WEBAPP_DESTINATION.append("index.html"))
.add(SOURCE.append(TEST_PRIMARY).template("App.spec.tsx"), to(TEST_PRIMARY).append("App.spec.tsx"))
.add(WEBAPP_SOURCE.template("config/setupTests.ts"), WEBAPP_DESTINATION.append("config/setupTests.ts"))
.add(PRIMARY_APP_SOURCE.template("StyledApp.tsx"), PRIMARY_APP_DESTINATION.append("App.tsx"))
.add(PRIMARY_APP_SOURCE.template("App.tsx"), PRIMARY_APP_DESTINATION.append("App.tsx"))
.add(PRIMARY_APP_SOURCE.template("App.css"), PRIMARY_APP_DESTINATION.append("App.css"))
.batch(WEBAPP_SOURCE.append(CONTENT_IMAGES), WEBAPP_DESTINATION.append(CONTENT_IMAGES))
.addFile("JHipster-Lite-neon-blue.png")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class ReactCoreModulesConfiguration {
public static final String REACT = "react";

@Bean
JHipsterModuleResource styledReactCoreModule(ReactCoreApplicationService react) {
JHipsterModuleResource reactCoreModule(ReactCoreApplicationService react) {
return JHipsterModuleResource
.builder()
.slug("react-core")
.propertiesDefinition(properties())
.apiDoc(new JHipsterModuleApiDoc("React", "Add React+Vite with minimal CSS"))
.organization(JHipsterModuleOrganization.builder().feature("client-core").addModuleDependency("init").build())
.tags("client", REACT)
.factory(react::buildModuleWithStyle);
.factory(react::buildModule);
}

private JHipsterModulePropertiesDefinition properties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public JHipsterModule buildSvelteModule(JHipsterModuleProperties properties) {
.add(SOURCE.file("jest.config.cjs"), to("jest.config.cjs"))
.add(SOURCE.file("vite.config.js"), to("vite.config.js"))
.add(SOURCE.append("src/main/webapp/routes").template("+page.svelte"), to("src/main/webapp/routes/+page.svelte"))
.add(PRIMARY_MAIN_SOURCE.template("StyledApp.svelte"), PRIMARY_MAIN_DESTINATION.append("App.svelte"))
.add(PRIMARY_MAIN_SOURCE.template("App.svelte"), PRIMARY_MAIN_DESTINATION.append("App.svelte"))
.add(PRIMARY_TEST_SOURCE.template("App.spec.ts"), PRIMARY_TEST_DESTINATION.append("App.spec.ts"))
.move(path(".lintstagedrc.js"), to(".lintstagedrc.cjs"))
.batch(SOURCE.file("src/main/webapp"), to("src/main/webapp"))
Expand Down
2 changes: 1 addition & 1 deletion src/test/features/react-jwt.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: React JWT

Scenario: Should apply react jwt module to styled react
Scenario: Should apply react jwt module to react
When I apply modules to default project
| init |
| react-core |
Expand Down
5 changes: 2 additions & 3 deletions src/test/features/react.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Feature: React modules

Scenario: Should apply styled react module
When I apply "react-core" module to default project with package json
Scenario: Should apply react module
When I apply "react-core" module to default project with package json
| baseName | jhipster |
Then I should have files in "src/main/webapp/app/common/primary/app"
| App.tsx |

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ReactCoreModulesFactoryTest {

@Test
void shouldBuildModuleWithStyle() {
JHipsterModule module = factory.buildModuleWithStyle(
JHipsterModule module = factory.buildModule(
JHipsterModulesFixture.propertiesBuilder(TestFileUtils.tmpDirForTest()).projectBaseName("jhipster").build()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,10 @@ class ReactJwtModuleFactoryTest {
private static final ReactJwtModuleFactory factory = new ReactJwtModuleFactory();

@Test
void shouldBuildModuleOnNotStyledApp() {
void shouldBuildModule() {
JHipsterModule module = factory.buildModule(properties());

ModuleAsserter asserter = assertThatModuleWithFiles(module, packageJsonFile(), notStyledApp());

assertReactApp(asserter);
}

private ModuleFile notStyledApp() {
return file("src/test/resources/projects/react-app/App.tsx", APP_TSX);
}

@Test
void shouldBuildModuleOnStyledApp() {
JHipsterModule module = factory.buildModule(properties());

ModuleAsserter asserter = assertThatModuleWithFiles(module, packageJsonFile(), styledApp(), appCss());
ModuleAsserter asserter = assertThatModuleWithFiles(module, packageJsonFile(), app(), appCss());

assertReactApp(asserter);
asserter
Expand All @@ -49,8 +36,8 @@ void shouldBuildModuleOnStyledApp() {
);
}

private ModuleFile styledApp() {
return file("src/test/resources/projects/react-app/StyledApp.tsx", APP_TSX);
private ModuleFile app() {
return file("src/test/resources/projects/react-app/App.tsx", APP_TSX);
}

private ModuleFile appCss() {
Expand Down
34 changes: 33 additions & 1 deletion src/test/resources/projects/react-app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
import './App.css';

function App() {
return <div id="app">Myapp</div>;
return (
<div className="App">
<div id="app">
<img alt="React logo" src="/content/images/ReactLogo.png" />
<br />
<img alt="JHipster logo" src="/content/images/JHipster-Lite-neon-blue.png" />
<h1>React + TypeScript + Vite</h1>
<p>
Recommended IDE setup:&nbsp;
<a href="https://code.visualstudio.com/" target="_blank">
VSCode
</a>
</p>

<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank" rel="noopener">
Vite Documentation
</a>
&nbsp;|&nbsp;
<a href="https://reactjs.org/docs/" target="_blank">
React Documentation
</a>
</p>

<p>
Edit&nbsp;
<code>src/main/webapp/app/common/primary/app/App.tsx</code> to test hot module replacement.
</p>
</div>
</div>
);
}

export default App;
37 changes: 0 additions & 37 deletions src/test/resources/projects/react-app/StyledApp.tsx

This file was deleted.

0 comments on commit 5ca8532

Please sign in to comment.