Last active
October 31, 2018 16:44
-
-
Save picheli20/544b5fa53a114e8b317e7c9c21618233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
import { CounterComponent } from './counter.component'; | |
describe('CounterComponent', () => { | |
let component: CounterComponent; | |
let fixture: ComponentFixture<CounterComponent>; | |
beforeEach(async(() => { | |
/** | |
* @uijar CounterComponent | |
*/ | |
TestBed.configureTestingModule({ | |
declarations: [ CounterComponent ] | |
}) | |
.compileComponents(); | |
})); | |
beforeEach(() => { | |
fixture = TestBed.createComponent(CounterComponent); | |
component = fixture.componentInstance; | |
fixture.detectChanges(); | |
}); | |
it('should create', () => { | |
expect(component).toBeTruthy(); | |
}); | |
describe('.increate()', () => { | |
/** @uijarexample Increase */ | |
it('should increase when called', () => { | |
expect(component.counter).toBe(0); | |
component.increase(); | |
expect(component.counter).toBe(1); | |
}); | |
}); | |
/** @uijarexample Different text */ | |
it('should change the default text', () => { | |
component.text = 'Im a text'; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input } from '@angular/core'; | |
/** | |
* @group Button & indicators | |
* @component Counter | |
* @description That's a counter component | |
*/ | |
@Component({ | |
selector: 'fb-counter', | |
templateUrl: './counter.component.html', | |
styleUrls: [ './counter.component.scss' ] | |
}) | |
export class CounterComponent { | |
/** | |
* Text that will show on the button | |
*/ | |
@Input() text = 'Default'; | |
/** | |
* Current acounter value | |
*/ | |
counter = 0; | |
/** | |
* Increate the counter | |
* @param amount [amount = 1] Amount that will be encreased | |
*/ | |
increase(amount = 1) { | |
this.counter += amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment