Skip to content

Commit 129560a

Browse files
committed
Add comments
1 parent fbf51b5 commit 129560a

10 files changed

+56
-44
lines changed

server.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ export function app(): express.Express {
2020
// Example Express Rest API endpoints
2121
// server.get('/api/**', (req, res) => { });
2222
// Serve static files from /browser
23-
server.get(
24-
'*.*',
25-
express.static(browserDistFolder, {
26-
maxAge: '1y',
27-
}),
28-
);
23+
server.get('*.*', express.static(browserDistFolder, {
24+
maxAge: '1y'
25+
}));
2926

3027
// All regular routes use the Angular engine
3128
server.get('*', (req, res, next) => {

src/app/app.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<h1>Angular Clicker Game</h1>
2-
<clicker-button></clicker-button>
2+
<!--clicker button component--><clicker-button
3+
></clicker-button>

src/app/app.component.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
clicker-button {
2-
line-height: 250%;
3-
}
2+
line-height: 250%; //set line height to 250% for clicker button component
3+
}

src/app/app.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ describe('AppComponent', () => {
99
});
1010

1111
it('should create the app', () => {
12-
const fixture = TestBed.createComponent(AppComponent);
12+
const fixture = TestBed.createComponent(AppComponent); //crease app component
1313
const app = fixture.componentInstance;
14-
expect(app).toBeTruthy();
14+
expect(app).toBeTruthy(); //assert app exists and is truthy
1515
});
1616

1717
it(`should have the 'angular-clicker-game' title`, () => {
1818
const fixture = TestBed.createComponent(AppComponent);
1919
const app = fixture.componentInstance;
20-
expect(app.title).toEqual('angular-clicker-game');
20+
expect(app.title).toEqual('angular-clicker-game'); //assert app title is `angular-clicker-game`
2121
});
2222

2323
it('should render title', () => {
2424
const fixture = TestBed.createComponent(AppComponent);
2525
fixture.detectChanges();
26-
const compiled = fixture.nativeElement as HTMLElement;
26+
const compiled = fixture.nativeElement as HTMLElement; //get native element
2727
expect(compiled.querySelector('h1')?.textContent).toContain(
2828
'Angular Clicker Game',
29-
);
29+
); //assert h1 (heading 1) text content is `Angular Clicker Game`
3030
});
3131
it('should display counter text', () => {
3232
const fixture = TestBed.createComponent(AppComponent);
3333
fixture.detectChanges();
3434
const compiled = fixture.nativeElement as HTMLElement;
35-
expect(compiled.querySelector('span')?.textContent).toContain('Count: 0');
35+
expect(compiled.querySelector('span')?.textContent).toContain('Count: 0'); //assert count test to 0
3636
});
3737
});

src/app/app.config.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { provideServerRendering } from '@angular/platform-server';
33
import { appConfig } from './app.config';
44

55
const serverConfig: ApplicationConfig = {
6-
providers: [provideServerRendering()],
6+
providers: [
7+
provideServerRendering()
8+
]
79
};
810

911
export const config = mergeApplicationConfig(appConfig, serverConfig);

src/app/clicker-button/clicker-button.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Amount to increase:
2-
<input
2+
<!--set amount to increase value to integer from 1 to 9--><input
33
type="number"
44
min="1"
55
max="9"
@@ -9,11 +9,13 @@
99
(change)="changeValue(+amount.value)"
1010
#amount
1111
/><br />
12-
<button (click)="increaseCount()">Increase Counter 1 Count</button>
12+
<!--increase count buttons--><button (click)="increaseCount()">
13+
Increase Counter 1 Count
14+
</button>
1315
<button (click)="increaseCount(true)">
1416
Increase Counter 1 Count by Amount
1517
</button>
16-
<span>Count: {{ count }}</span
18+
<!--counter values text--><span>Count: {{ count }}</span
1719
><br />
1820
<button (click)="increaseCount2()">Increase Counter 2 Count</button>
1921
<button (click)="increaseCount2(true)">
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
@button-normal-width: 5px;
1+
@button-normal-width: 5px; //normal width for button
22
button {
3-
margin: @button-normal-width;
4-
border-width: (@button-normal-width / 2);
5-
border-color: black;
6-
font-variant-numeric: tabular-nums;
3+
//set all buttons
4+
margin: @button-normal-width; //set to margin normal width of button
5+
border-width: (
6+
@button-normal-width / 2
7+
); //set border width to half of normal width of button
8+
border-color: black; //set border color to black
9+
font-variant-numeric: tabular-nums; //set font variant for buttons to tabular numbers
710
}

src/app/clicker-button/clicker-button.component.spec.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
33
import { ClickerButtonComponent } from './clicker-button.component';
44

55
describe('ClickerButtonComponent', () => {
6-
let component: ClickerButtonComponent;
7-
let fixture: ComponentFixture<ClickerButtonComponent>;
6+
let component: ClickerButtonComponent; //clicker button component
7+
let fixture: ComponentFixture<ClickerButtonComponent>; //component fixture
88

99
beforeEach(async () => {
1010
await TestBed.configureTestingModule({
1111
imports: [ClickerButtonComponent],
12-
}).compileComponents();
12+
}).compileComponents(); //compile components
1313

1414
fixture = TestBed.createComponent(ClickerButtonComponent);
1515
component = fixture.componentInstance;
16-
fixture.detectChanges();
16+
fixture.detectChanges(); //detect changes in fixture
1717
});
1818

1919
it('should create', () => {
20-
expect(component).toBeTruthy();
20+
expect(component).toBeTruthy(); //assert component exists and is truthy
2121
});
2222
it('should initialize values when app is loaded', () => {
23-
expect(component.count).toEqual(0);
23+
expect(component.count).toEqual(0); //assert all component values to 0
2424
expect(component.count2).toEqual(0);
2525
expect(component.count3).toEqual(0);
2626
});
2727
it('should update counts', () => {
28-
component.increaseCount();
28+
component.increaseCount(); //increase count
2929
expect(component.count).toEqual(1);
30-
component.changeValue(5);
31-
component.increaseCount(true);
30+
component.changeValue(5); //change amount value
31+
component.increaseCount(true); //increase count by specified amount value
3232
expect(component.count).toEqual(6);
3333
component.increaseCount2(true);
3434
expect(component.count2).toEqual(30);
@@ -39,15 +39,18 @@ describe('ClickerButtonComponent', () => {
3939
expect(component.count3).toEqual(240);
4040
});
4141
it('should update non-integer amount values', () => {
42-
component.changeValue(3.75);
42+
//assert non-integer amount values
43+
component.changeValue(3.75); //non-integer value
4344
expect(component.amount).toEqual(3);
4445
});
4546
it('should update amount values greater than 9', () => {
46-
component.changeValue(25);
47+
//assert large amount values
48+
component.changeValue(25); //number greater than 9
4749
expect(component.amount).toEqual(9);
4850
});
4951
it('should update amount values less than 1', () => {
50-
component.changeValue(-7);
52+
//assert negative amount values
53+
component.changeValue(-7); //number less than 1
5154
expect(component.amount).toEqual(1);
5255
});
5356
});

src/app/clicker-button/clicker-button.component.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@ import { Component } from '@angular/core';
88
styleUrl: './clicker-button.component.less',
99
})
1010
export class ClickerButtonComponent {
11-
count: number = 0;
11+
count: number = 0; //set counter variables to 0
1212
count2: number = 0;
1313
count3: number = 0;
14-
amount: number = 1;
14+
amount: number = 1; //set default amount to 1
1515
increaseCount(amountSpecified: boolean = false): void {
16-
this.count += amountSpecified ? this.amount : 1;
16+
//if amount is specified, increase by specified amount, else increase by 1
17+
this.count += amountSpecified ? this.amount : 1; //increase first count
1718
}
1819
increaseCount2(amountSpecified: boolean = false): void {
19-
this.count2 += amountSpecified ? this.amount * this.count : this.count;
20+
//if amount is specified, increase by specified amount times first count, else increase by first count
21+
this.count2 += amountSpecified ? this.amount * this.count : this.count; //increase second count
2022
}
2123
increaseCount3(amountSpecified: boolean = false): void {
22-
this.count3 += amountSpecified ? this.amount * this.count2 : this.count2;
24+
//if amount is specified, increase by specified amount times second count, else increase by second count
25+
this.count3 += amountSpecified ? this.amount * this.count2 : this.count2; //increase third count
2326
}
2427
changeValue(newValue: number) {
25-
this.amount = parseInt(String(Math.min(9, Math.max(1, newValue))));
28+
//set amount value based on new value number
29+
this.amount = parseInt(String(Math.min(9, Math.max(1, newValue)))); //set amount to integer from 1 to 9
2630
}
2731
}

src/styles.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* {
2-
font-family: system-ui, sans-serif;
3-
}
2+
font-family: system-ui, sans-serif; //set whole content to system-ui or sans=serif font text
3+
}

0 commit comments

Comments
 (0)