Skip to content

Commit f3fa47b

Browse files
committed
StandaloneServiceCounterComponent
1 parent e82e043 commit f3fa47b

11 files changed

+277
-149
lines changed

src/app/app.module.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ import { AppComponent } from './app.component';
1212
import { AppRoutingModule } from './app.routing.module';
1313
import { CounterComponent } from './components/counter/counter.component';
1414
import { HomeComponent } from './components/home/home.component';
15-
import { NgRxCounterComponent } from './components/ngrx-counter/ngrx-counter.component';
16-
import { ServiceCounterComponent } from './components/service-counter/service-counter.component';
17-
import { StandaloneCounterComponent } from './components/standalone-counter/standalone-counter.component';
15+
import {
16+
NgRxCounterComponent,
17+
} from './components/ngrx-counter/ngrx-counter.component';
18+
import {
19+
ServiceCounterComponent,
20+
} from './components/service-counter/service-counter.component';
21+
import {
22+
StandaloneServiceCounterComponent,
23+
} from './components/standalone-service-counter/standalone-service-counter.component';
1824
import { CounterEffects } from './effects/counter.effects';
1925
import { reducers } from './reducers';
2026
import { CounterApiService } from './services/counter-api.service';
@@ -33,7 +39,7 @@ import { CounterService } from './services/counter.service';
3339
HttpClientModule,
3440

3541
AppRoutingModule,
36-
StandaloneCounterComponent,
42+
StandaloneServiceCounterComponent,
3743

3844
// NgRx Store
3945
StoreModule.forRoot(reducers, {

src/app/app.routing.module.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import { NgModule } from '@angular/core';
2-
import { RouterModule, Routes } from '@angular/router';
2+
import {
3+
RouterModule,
4+
Routes,
5+
} from '@angular/router';
36

47
import { CounterComponent } from './components/counter/counter.component';
58
import { HomeComponent } from './components/home/home.component';
6-
import { NgRxCounterComponent } from './components/ngrx-counter/ngrx-counter.component';
7-
import { ServiceCounterComponent } from './components/service-counter/service-counter.component';
8-
import { StandaloneCounterComponent } from './components/standalone-counter/standalone-counter.component';
9+
import {
10+
NgRxCounterComponent,
11+
} from './components/ngrx-counter/ngrx-counter.component';
12+
import {
13+
ServiceCounterComponent,
14+
} from './components/service-counter/service-counter.component';
15+
import {
16+
StandaloneServiceCounterComponent,
17+
} from './components/standalone-service-counter/standalone-service-counter.component';
918

1019
export const routes: Routes = [
1120
{ path: '', pathMatch: 'full', component: HomeComponent },
1221
{ path: 'counter-component', component: CounterComponent },
13-
{ path: 'standalone-counter-component', component: StandaloneCounterComponent },
22+
{ path: 'standalone-counter-component', component: StandaloneServiceCounterComponent },
1423
{ path: 'service-counter-component', component: ServiceCounterComponent },
1524
{ path: 'ngrx-counter-component', component: NgRxCounterComponent },
1625
];

src/app/components/service-counter/service-counter.component.spec.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { BehaviorSubject, Observable, of } from 'rxjs';
1+
import {
2+
ComponentFixture,
3+
TestBed,
4+
} from '@angular/core/testing';
5+
6+
import {
7+
BehaviorSubject,
8+
Observable,
9+
of,
10+
} from 'rxjs';
311

412
import { CounterService } from '../../services/counter.service';
5-
import { click, expectText, setFieldValue } from '../../spec-helpers/element.spec-helper';
13+
import {
14+
click,
15+
expectText,
16+
setFieldValue,
17+
} from '../../spec-helpers/element.spec-helper';
618
import { ServiceCounterComponent } from './service-counter.component';
719

820
describe('ServiceCounterComponent: integration test', () => {
9-
let component: ServiceCounterComponent;
1021
let fixture: ComponentFixture<ServiceCounterComponent>;
1122

1223
beforeEach(async () => {
@@ -16,7 +27,6 @@ describe('ServiceCounterComponent: integration test', () => {
1627
}).compileComponents();
1728

1829
fixture = TestBed.createComponent(ServiceCounterComponent);
19-
component = fixture.componentInstance;
2030
fixture.detectChanges();
2131
});
2232

@@ -48,7 +58,6 @@ describe('ServiceCounterComponent: integration test', () => {
4858
describe('ServiceCounterComponent: unit test', () => {
4959
const currentCount = 123;
5060

51-
let component: ServiceCounterComponent;
5261
let fixture: ComponentFixture<ServiceCounterComponent>;
5362
// Declare shared variable
5463
let fakeCounterService: CounterService;
@@ -69,7 +78,6 @@ describe('ServiceCounterComponent: unit test', () => {
6978
}).compileComponents();
7079

7180
fixture = TestBed.createComponent(ServiceCounterComponent);
72-
component = fixture.componentInstance;
7381
fixture.detectChanges();
7482
});
7583

src/app/components/standalone-counter/standalone-counter.component.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/app/components/standalone-counter/standalone-counter.component.spec.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/app/components/standalone-counter/standalone-counter.component.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h1>Standalone counter connected to the service</h1>
2+
3+
<p>
4+
<strong data-testid="count">{{ count$ | async }}</strong>
5+
</p>
6+
7+
<p>
8+
<button (click)="increment()" data-testid="increment-button">+</button>
9+
<button (click)="decrement()" data-testid="decrement-button">-</button>
10+
</p>
11+
12+
<p>
13+
<input type="number" #input data-testid="reset-input" />
14+
<button (click)="reset(input.value)" data-testid="reset-button">Reset</button>
15+
</p>

0 commit comments

Comments
 (0)