Skip to content

Instantly share code, notes, and snippets.

@picheli20
Last active October 31, 2018 16:44
Show Gist options
  • Save picheli20/544b5fa53a114e8b317e7c9c21618233 to your computer and use it in GitHub Desktop.
Save picheli20/544b5fa53a114e8b317e7c9c21618233 to your computer and use it in GitHub Desktop.
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';
});
});
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