From dc94348960e6ce67ea3be74c5ac5773a8df15e24 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Thu, 9 May 2024 09:51:34 -0700 Subject: [PATCH] refactor(FeaturesComponent): Convert to standalone (#1787) --- src/app/app-routing.module.ts | 2 +- src/app/features/features-routing.module.ts | 11 --------- src/app/features/features.component.spec.ts | 17 +++++++------ src/app/features/features.component.ts | 27 +++++++++++++++------ src/app/features/features.module.spec.ts | 13 ---------- src/app/features/features.module.ts | 22 ----------------- 6 files changed, 29 insertions(+), 63 deletions(-) delete mode 100644 src/app/features/features-routing.module.ts delete mode 100644 src/app/features/features.module.spec.ts delete mode 100644 src/app/features/features.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f0107582a75..81a0b9427bf 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -16,7 +16,7 @@ const routes: Routes = [ }, { path: 'features', - loadChildren: () => import('./features/features.module').then((m) => m.FeaturesModule) + loadComponent: () => import('./features/features.component').then((m) => m.FeaturesComponent) }, { path: 'forgot', diff --git a/src/app/features/features-routing.module.ts b/src/app/features/features-routing.module.ts deleted file mode 100644 index 7a4515b28ad..00000000000 --- a/src/app/features/features-routing.module.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { FeaturesComponent } from './features.component'; - -const featuresRoutes: Routes = [{ path: '', component: FeaturesComponent }]; - -@NgModule({ - imports: [RouterModule.forChild(featuresRoutes)], - exports: [RouterModule] -}) -export class FeaturesRoutingModule {} diff --git a/src/app/features/features.component.spec.ts b/src/app/features/features.component.spec.ts index 4241a71ebad..4e0ac8b769a 100644 --- a/src/app/features/features.component.spec.ts +++ b/src/app/features/features.component.spec.ts @@ -1,18 +1,19 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; - import { FeaturesComponent } from './features.component'; +import { provideRouter } from '@angular/router'; describe('FeaturesComponent', () => { let component: FeaturesComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [FeaturesComponent], - schemas: [NO_ERRORS_SCHEMA] - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + imports: [FeaturesComponent], + providers: [provideRouter([])] + }).compileComponents(); + }) + ); beforeEach(() => { fixture = TestBed.createComponent(FeaturesComponent); diff --git a/src/app/features/features.component.ts b/src/app/features/features.component.ts index b547fbbb097..3cdd15c6c5c 100644 --- a/src/app/features/features.component.ts +++ b/src/app/features/features.component.ts @@ -1,12 +1,23 @@ -import { Component, OnInit } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatButtonModule } from '@angular/material/button'; +import { MatDividerModule } from '@angular/material/divider'; +import { MatIconModule } from '@angular/material/icon'; +import { RouterModule } from '@angular/router'; @Component({ + imports: [ + CommonModule, + FlexLayoutModule, + MatButtonModule, + MatDividerModule, + MatIconModule, + RouterModule + ], selector: 'app-features', - templateUrl: './features.component.html', - styleUrls: ['./features.component.scss'] + standalone: true, + styleUrl: './features.component.scss', + templateUrl: './features.component.html' }) -export class FeaturesComponent implements OnInit { - constructor() {} - - ngOnInit() {} -} +export class FeaturesComponent {} diff --git a/src/app/features/features.module.spec.ts b/src/app/features/features.module.spec.ts deleted file mode 100644 index 33d10d08d6a..00000000000 --- a/src/app/features/features.module.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { FeaturesModule } from './features.module'; - -describe('FeaturesModule', () => { - let featuresModule: FeaturesModule; - - beforeEach(() => { - featuresModule = new FeaturesModule(); - }); - - it('should create an instance', () => { - expect(featuresModule).toBeTruthy(); - }); -}); diff --git a/src/app/features/features.module.ts b/src/app/features/features.module.ts deleted file mode 100644 index 5de6395816d..00000000000 --- a/src/app/features/features.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FlexLayoutModule } from '@angular/flex-layout'; -import { MatDividerModule } from '@angular/material/divider'; -import { MatIconModule } from '@angular/material/icon'; -import { FeaturesComponent } from './features.component'; -import { FeaturesRoutingModule } from './features-routing.module'; -import { SharedModule } from '../modules/shared/shared.module'; - -@NgModule({ - imports: [ - CommonModule, - FlexLayoutModule, - MatDividerModule, - MatIconModule, - FeaturesRoutingModule, - SharedModule - ], - declarations: [FeaturesComponent], - exports: [FeaturesComponent, SharedModule] -}) -export class FeaturesModule {}