Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Mar 27, 2017
1 parent 13a258e commit f1e2d89
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/lib/input/input-container.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ describe('MdInputContainer', function () {
MdInputContainerMissingMdInputTestController,
MdInputContainerMultipleHintTestController,
MdInputContainerMultipleHintMixedTestController,
MdInputContainerWithDynamicPlaceholder
MdInputContainerWithDynamicPlaceholder,
MdInputContainerWithPrefixAndSuffix
],
});

Expand Down Expand Up @@ -551,6 +552,29 @@ describe('MdInputContainer', function () {
expect(labelEl.classList).not.toContain('mat-float');
});

it('should not have prefix and suffix elements when none are specified', () => {
let fixture = TestBed.createComponent(MdInputContainerWithId);
fixture.detectChanges();

let prefixEl = fixture.debugElement.query(By.css('.mat-input-prefix'));
let suffixEl = fixture.debugElement.query(By.css('.mat-input-suffix'));

expect(prefixEl).toBeNull();
expect(suffixEl).toBeNull();
});

it('should add prefix and suffix elements when specified', () => {
let fixture = TestBed.createComponent(MdInputContainerWithPrefixAndSuffix);
fixture.detectChanges();

let prefixEl = fixture.debugElement.query(By.css('.mat-input-prefix'));
let suffixEl = fixture.debugElement.query(By.css('.mat-input-suffix'));

expect(prefixEl).not.toBeNull();
expect(suffixEl).not.toBeNull();
expect(prefixEl.nativeElement.innerText.trim()).toEqual('Prefix');
expect(suffixEl.nativeElement.innerText.trim()).toEqual('Suffix');
});
});

@Component({
Expand Down Expand Up @@ -775,3 +799,14 @@ class MdTextareaWithBindings {
template: `<md-input-container><input></md-input-container>`
})
class MdInputContainerMissingMdInputTestController {}

@Component({
template: `
<md-input-container>
<div mdPrefix>Prefix</div>
<input mdInput>
<div mdSuffix>Suffix</div>
</md-input-container>
`
})
class MdInputContainerWithPrefixAndSuffix {}

0 comments on commit f1e2d89

Please sign in to comment.