forked from andrucz/ionic2-rating
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathionic2-rating.spec.ts
49 lines (40 loc) · 1.27 KB
/
ionic2-rating.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { async, TestBed, ComponentFixture, ComponentFixtureAutoDetect } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { } from 'jasmine';
import { Ionic2Rating } from './ionic2-rating';
describe('Ionic2Rating', () => {
let component: Ionic2Rating;
let fixture: ComponentFixture<Ionic2Rating>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [Ionic2Rating],
imports: [
IonicModule.forRoot(Ionic2Rating)
],
providers: [
{ provide: ComponentFixtureAutoDetect, useValue: true }
]
});
}));
beforeEach(() => {
fixture = TestBed.createComponent(Ionic2Rating);
component = fixture.componentInstance;
de = fixture.debugElement.query(By.css('ul'));
el = de.nativeElement;
});
it('should be created', () => {
expect(component instanceof Ionic2Rating).toBe(true);
});
it('should show 5 stars by default', () => {
expect(el.childElementCount).toBe(5);
});
it('should reflect max value', () => {
component.max = 10;
fixture.detectChanges();
expect(el.childElementCount).toBe(10);
});
});