Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Mar 22, 2017
1 parent 8fe05ab commit f0fa205
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 @@ -49,7 +49,8 @@ describe('MdInputContainer', function () {
MdInputContainerMissingMdInputTestController,
MdInputContainerMultipleHintTestController,
MdInputContainerMultipleHintMixedTestController,
MdInputContainerWithDynamicPlaceholder
MdInputContainerWithDynamicPlaceholder,
MdInputContainerWithPrefixAndSuffix
],
});

Expand Down Expand Up @@ -550,6 +551,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,6 +799,17 @@ class MdTextareaWithBindings {
})
class MdInputContainerMissingMdInputTestController {}

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

/**
* Gets a RegExp used to detect an angular wrapped error message.
* See https://github.com/angular/angular/issues/8348
Expand Down

0 comments on commit f0fa205

Please sign in to comment.