Skip to content

Commit 9e80283

Browse files
committed
add test for attributes class and style
1 parent 89672f4 commit 9e80283

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/demo-app/input/input-demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<td><input md-input placeholder="Long Last Name That Will Be Truncated" style="width: 100%"></td>
1212
</tr></table>
1313
<p>
14-
<textarea md-input class="demo-full-width" placeholder="Address" value="1600 Amphitheatre Pkway"></textarea>
15-
<textarea md-input class="demo-full-width" placeholder="Address 2"></textarea>
14+
<textarea md-textarea class="demo-full-width" placeholder="Address" value="1600 Amphitheatre Pkway"></textarea>
15+
<textarea md-textarea class="demo-full-width" placeholder="Address 2"></textarea>
1616
</p>
1717
</form>
1818
</md-card-content>

src/lib/input/input.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('MdInput', function () {
1313
TestBed.configureTestingModule({
1414
imports: [MdInputModule.forRoot(), FormsModule, ProjectionModule.forRoot()],
1515
declarations: [
16+
MdInputStyleClassTransferedTestComponent,
1617
MdInputNumberTypeConservedTestComponent,
1718
MdInputInvalidTypeTestController,
1819
MdInputBaseTestController,
@@ -49,6 +50,15 @@ describe('MdInput', function () {
4950
});
5051
}));
5152

53+
it('moves the class and style to the outer container', async(() => {
54+
let fixture = TestBed.createComponent(MdInputStyleClassTransferedTestComponent);
55+
fixture.detectChanges();
56+
57+
let el = fixture.debugElement.query(By.directive(MdInput)).nativeElement;
58+
expect(el.getAttribute('class')).toBeNull();
59+
expect(el.getAttribute('style')).toBeNull();
60+
}));
61+
5262
it('counts characters', async(() => {
5363
let fixture = TestBed.createComponent(MdInputBaseTestController);
5464
let instance = fixture.componentInstance;
@@ -88,6 +98,10 @@ describe('MdInput', function () {
8898

8999
});
90100

101+
@Component({template: `<input md-input type="number" class="test-class" style="color: 123456">`})
102+
class MdInputStyleClassTransferedTestComponent {
103+
}
104+
91105
@Component({template: `<input md-input type="number" [(ngModel)]="value">`})
92106
class MdInputNumberTypeConservedTestComponent {
93107
value: number = 0;
@@ -103,7 +117,7 @@ class MdInputBaseTestController {
103117

104118
@Component({
105119
template: `
106-
<textarea md-input [rows]="rows" [cols]="cols" [wrap]="wrap" placeholder="Snacks">
120+
<textarea md-textarea [rows]="rows" [cols]="cols" [wrap]="wrap" placeholder="Snacks">
107121
</textarea>
108122
`})
109123
class MdTextareaWithBindings {

src/lib/input/input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MD_INPUT_INVALID_INPUT_TYPE = [
4242
*/
4343
@Component({
4444
moduleId: module.id,
45-
selector: 'input[md-input], textarea[md-input]',
45+
selector: 'input[md-input], textarea[md-textarea]',
4646
templateUrl: 'input.html',
4747
styleUrls: ['input.css'],
4848
encapsulation: ViewEncapsulation.None,

0 commit comments

Comments
 (0)