@@ -28,7 +28,7 @@ export function runHarnessTests(
28
28
29
29
it ( 'should load all input harnesses' , async ( ) => {
30
30
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
31
- expect ( inputs . length ) . toBe ( 3 ) ;
31
+ expect ( inputs . length ) . toBe ( 4 ) ;
32
32
} ) ;
33
33
34
34
it ( 'should load input with specific id' , async ( ) => {
@@ -49,48 +49,55 @@ export function runHarnessTests(
49
49
50
50
it ( 'should be able to get id of input' , async ( ) => {
51
51
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
52
- expect ( inputs . length ) . toBe ( 3 ) ;
52
+ expect ( inputs . length ) . toBe ( 4 ) ;
53
53
expect ( await inputs [ 0 ] . getId ( ) ) . toMatch ( / m a t - i n p u t - \d + / ) ;
54
54
expect ( await inputs [ 1 ] . getId ( ) ) . toMatch ( / m a t - i n p u t - \d + / ) ;
55
55
expect ( await inputs [ 2 ] . getId ( ) ) . toBe ( 'myTextarea' ) ;
56
+ expect ( await inputs [ 3 ] . getId ( ) ) . toBe ( 'nativeControl' ) ;
56
57
} ) ;
57
58
58
59
it ( 'should be able to get name of input' , async ( ) => {
59
60
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
60
- expect ( inputs . length ) . toBe ( 3 ) ;
61
+ expect ( inputs . length ) . toBe ( 4 ) ;
61
62
expect ( await inputs [ 0 ] . getName ( ) ) . toBe ( 'favorite-food' ) ;
62
63
expect ( await inputs [ 1 ] . getName ( ) ) . toBe ( '' ) ;
63
64
expect ( await inputs [ 2 ] . getName ( ) ) . toBe ( '' ) ;
65
+ expect ( await inputs [ 3 ] . getName ( ) ) . toBe ( '' ) ;
64
66
} ) ;
65
67
66
68
it ( 'should be able to get value of input' , async ( ) => {
67
69
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
68
- expect ( inputs . length ) . toBe ( 3 ) ;
70
+ expect ( inputs . length ) . toBe ( 4 ) ;
69
71
expect ( await inputs [ 0 ] . getValue ( ) ) . toBe ( 'Sushi' ) ;
70
72
expect ( await inputs [ 1 ] . getValue ( ) ) . toBe ( '' ) ;
71
73
expect ( await inputs [ 2 ] . getValue ( ) ) . toBe ( '' ) ;
74
+ expect ( await inputs [ 3 ] . getValue ( ) ) . toBe ( '' ) ;
72
75
} ) ;
73
76
74
77
it ( 'should be able to set value of input' , async ( ) => {
75
78
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
76
- expect ( inputs . length ) . toBe ( 3 ) ;
79
+ expect ( inputs . length ) . toBe ( 4 ) ;
77
80
expect ( await inputs [ 0 ] . getValue ( ) ) . toBe ( 'Sushi' ) ;
78
81
expect ( await inputs [ 1 ] . getValue ( ) ) . toBe ( '' ) ;
82
+ expect ( await inputs [ 3 ] . getValue ( ) ) . toBe ( '' ) ;
79
83
80
84
await inputs [ 0 ] . setValue ( '' ) ;
81
85
await inputs [ 2 ] . setValue ( 'new-value' ) ;
86
+ await inputs [ 3 ] . setValue ( 'new-value' ) ;
82
87
83
88
expect ( await inputs [ 0 ] . getValue ( ) ) . toBe ( '' ) ;
84
89
expect ( await inputs [ 2 ] . getValue ( ) ) . toBe ( 'new-value' ) ;
90
+ expect ( await inputs [ 3 ] . getValue ( ) ) . toBe ( 'new-value' ) ;
85
91
} ) ;
86
92
87
93
it ( 'should be able to get disabled state' , async ( ) => {
88
94
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
89
- expect ( inputs . length ) . toBe ( 3 ) ;
95
+ expect ( inputs . length ) . toBe ( 4 ) ;
90
96
91
97
expect ( await inputs [ 0 ] . isDisabled ( ) ) . toBe ( false ) ;
92
98
expect ( await inputs [ 1 ] . isDisabled ( ) ) . toBe ( false ) ;
93
99
expect ( await inputs [ 2 ] . isDisabled ( ) ) . toBe ( false ) ;
100
+ expect ( await inputs [ 3 ] . isDisabled ( ) ) . toBe ( false ) ;
94
101
95
102
fixture . componentInstance . disabled = true ;
96
103
@@ -99,11 +106,12 @@ export function runHarnessTests(
99
106
100
107
it ( 'should be able to get readonly state' , async ( ) => {
101
108
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
102
- expect ( inputs . length ) . toBe ( 3 ) ;
109
+ expect ( inputs . length ) . toBe ( 4 ) ;
103
110
104
111
expect ( await inputs [ 0 ] . isReadonly ( ) ) . toBe ( false ) ;
105
112
expect ( await inputs [ 1 ] . isReadonly ( ) ) . toBe ( false ) ;
106
113
expect ( await inputs [ 2 ] . isReadonly ( ) ) . toBe ( false ) ;
114
+ expect ( await inputs [ 3 ] . isReadonly ( ) ) . toBe ( false ) ;
107
115
108
116
fixture . componentInstance . readonly = true ;
109
117
@@ -112,11 +120,12 @@ export function runHarnessTests(
112
120
113
121
it ( 'should be able to get required state' , async ( ) => {
114
122
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
115
- expect ( inputs . length ) . toBe ( 3 ) ;
123
+ expect ( inputs . length ) . toBe ( 4 ) ;
116
124
117
125
expect ( await inputs [ 0 ] . isRequired ( ) ) . toBe ( false ) ;
118
126
expect ( await inputs [ 1 ] . isRequired ( ) ) . toBe ( false ) ;
119
127
expect ( await inputs [ 2 ] . isRequired ( ) ) . toBe ( false ) ;
128
+ expect ( await inputs [ 3 ] . isRequired ( ) ) . toBe ( false ) ;
120
129
121
130
fixture . componentInstance . required = true ;
122
131
@@ -125,18 +134,20 @@ export function runHarnessTests(
125
134
126
135
it ( 'should be able to get placeholder of input' , async ( ) => {
127
136
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
128
- expect ( inputs . length ) . toBe ( 3 ) ;
137
+ expect ( inputs . length ) . toBe ( 4 ) ;
129
138
expect ( await inputs [ 0 ] . getPlaceholder ( ) ) . toBe ( 'Favorite food' ) ;
130
139
expect ( await inputs [ 1 ] . getPlaceholder ( ) ) . toBe ( '' ) ;
131
140
expect ( await inputs [ 2 ] . getPlaceholder ( ) ) . toBe ( 'Leave a comment' ) ;
141
+ expect ( await inputs [ 3 ] . getPlaceholder ( ) ) . toBe ( 'Native control' ) ;
132
142
} ) ;
133
143
134
144
it ( 'should be able to get type of input' , async ( ) => {
135
145
const inputs = await loader . getAllHarnesses ( inputHarness ) ;
136
- expect ( inputs . length ) . toBe ( 3 ) ;
146
+ expect ( inputs . length ) . toBe ( 4 ) ;
137
147
expect ( await inputs [ 0 ] . getType ( ) ) . toBe ( 'text' ) ;
138
148
expect ( await inputs [ 1 ] . getType ( ) ) . toBe ( 'number' ) ;
139
149
expect ( await inputs [ 2 ] . getType ( ) ) . toBe ( 'textarea' ) ;
150
+ expect ( await inputs [ 3 ] . getType ( ) ) . toBe ( 'text' ) ;
140
151
141
152
fixture . componentInstance . inputType = 'text' ;
142
153
@@ -180,6 +191,10 @@ function getActiveElementTagName() {
180
191
<mat-form-field>
181
192
<textarea id="myTextarea" matInput placeholder="Leave a comment"></textarea>
182
193
</mat-form-field>
194
+
195
+ <mat-form-field>
196
+ <input matNativeControl placeholder="Native control" id="nativeControl">
197
+ </mat-form-field>
183
198
`
184
199
} )
185
200
class InputHarnessTest {
0 commit comments