Skip to content

Instantly share code, notes, and snippets.

@RayLuxembourg
Created September 10, 2018 09:55
Show Gist options
  • Save RayLuxembourg/f0529bd138848b13845f6ff5d6b8b222 to your computer and use it in GitHub Desktop.
Save RayLuxembourg/f0529bd138848b13845f6ff5d6b8b222 to your computer and use it in GitHub Desktop.
Simple counter test
describe('CounterComponent', () => {
let component: CounterComponent;
let fixture: ComponentFixture<CounterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CounterComponent]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CounterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should increment', () => {
component.count();
expect(component.counts).toBe(1);
component.count();
expect(component.counts).toBe(2);
});
it('should decrement', () => {
component.counts = 5;
component.subtruct();
expect(component.counts).toBe(4);
component.subtruct();
expect(component.counts).toBe(3);
});
it('should reset', () => {
component.counts = 5;
component.subtruct();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment