Skip to content

Commit

Permalink
test(MdInput): Update empty() check tests to match new test syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
drager committed Sep 6, 2016
1 parent 5882611 commit ba12423
Showing 1 changed file with 48 additions and 68 deletions.
116 changes: 48 additions & 68 deletions src/lib/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ describe('MdInput', function () {
MdInputWithMin,
MdInputWithStep,
MdInputWithTabindex,
MdInputDateTestController,
MdInputTextTestController,
MdInputPasswordTestController,
MdInputNumberTestController,
],
});

Expand All @@ -70,60 +74,52 @@ describe('MdInput', function () {
if (isInternetExplorer11()) {
return;
}
builder.createAsync(MdInputDateTestController)
.then(fixture => {
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 fixture = TestBed.createComponent(MdInputDateTestController);
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);
}));

it('should treat text input type as empty at init', async(() => {
if (isInternetExplorer11()) {
return;
}
builder.createAsync(MdInputTextTestController)
.then(fixture => {
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 fixture = TestBed.createComponent(MdInputTextTestController);
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);
}));

it('should treat password input type as empty at init', async(() => {
if (isInternetExplorer11()) {
return;
}
builder.createAsync(MdInputPasswordTestController)
.then(fixture => {
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 fixture = TestBed.createComponent(MdInputPasswordTestController);
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);
}));

it('should treat number input type as empty at init', async(() => {
if (isInternetExplorer11()) {
return;
}
builder.createAsync(MdInputNumberTestController)
.then(fixture => {
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 fixture = TestBed.createComponent(MdInputNumberTestController);
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);
}));

// TODO(kara): update when core/testing adds fix
Expand Down Expand Up @@ -765,38 +761,22 @@ class MdInputWithStep { }
@Component({template: `<md-input [tabindex]="tabIndex"></md-input>`})
class MdInputWithTabindex { }

@Component({
selector: 'test-input-controller',
template: `
<md-input type="date" [placeholder]="placeholder"></md-input>
`,
directives: [MdInput]
})
class MdInputDateTestController {}
@Component({template: `<md-input type="date" [placeholder]="placeholder"></md-input>`})
class MdInputDateTestController {
placeholder: string = '';
}

@Component({
selector: 'test-input-controller',
template: `
<md-input type="text" [placeholder]="placeholder"></md-input>
`,
directives: [MdInput]
})
class MdInputTextTestController {}
@Component({template: `<md-input type="text" [placeholder]="placeholder"></md-input>`})
class MdInputTextTestController {
placeholder: string = '';
}

@Component({
selector: 'test-input-controller',
template: `
<md-input type="password" [placeholder]="placeholder"></md-input>
`,
directives: [MdInput]
})
class MdInputPasswordTestController {}
@Component({template: `<md-input type="password" [placeholder]="placeholder"></md-input>`})
class MdInputPasswordTestController {
placeholder: string = '';
}

@Component({
selector: 'test-input-controller',
template: `
<md-input type="number" [placeholder]="placeholder"></md-input>
`,
directives: [MdInput]
})
class MdInputNumberTestController {}
@Component({template: `<md-input type="number" [placeholder]="placeholder"></md-input>`})
class MdInputNumberTestController {
placeholder: string = '';
}

0 comments on commit ba12423

Please sign in to comment.