Skip to content

Commit

Permalink
test(MdInput): Update empty check tests to match the other tests new …
Browse files Browse the repository at this point in the history
…syntax
  • Loading branch information
drager committed Jul 14, 2016
1 parent 121486a commit 22b0576
Showing 1 changed file with 32 additions and 40 deletions.
72 changes: 32 additions & 40 deletions src/components/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,61 +35,53 @@ describe('MdInput', function () {
});
}));

it('should not be treated as empty if type is date', () => {
return builder.createAsync(MdInputDateTestController)
it('should not be treated as empty if type is date', async(() => {
builder.createAsync(MdInputDateTestController)
.then(fixture => {
fakeAsync(() => {
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();

let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(false);
})();
let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(false);
});
});
}));

it('should treat text input type as empty at init', () => {
return builder.createAsync(MdInputTextTestController)
it('should treat text input type as empty at init', async(() => {
builder.createAsync(MdInputTextTestController)
.then(fixture => {
fakeAsync(() => {
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();

let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(true);
})();
let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(true);
});
});
}));

it('should treat password input type as empty at init', () => {
return builder.createAsync(MdInputPasswordTestController)
it('should treat password input type as empty at init', async(() => {
builder.createAsync(MdInputPasswordTestController)
.then(fixture => {
fakeAsync(() => {
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();

let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(true);
})();
let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(true);
});
});
}));

it('should treat number input type as empty at init', () => {
return builder.createAsync(MdInputNumberTestController)
it('should treat number input type as empty at init', async(() => {
builder.createAsync(MdInputNumberTestController)
.then(fixture => {
fakeAsync(() => {
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();
fixture.componentInstance.placeholder = 'Placeholder';
fixture.detectChanges();

let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(true);
})();
let el = fixture.debugElement.query(By.css('label')).nativeElement;
expect(el).not.toBeNull();
expect(el.className.includes('md-empty')).toBe(true);
});
});
}));

it('support ngModel', async(() => {
builder.createAsync(MdInputBaseTestController)
Expand Down

0 comments on commit 22b0576

Please sign in to comment.