@@ -3,32 +3,32 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
33import { ClickerButtonComponent } from './clicker-button.component' ;
44
55describe ( '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} ) ;
0 commit comments