Skip to content

Commit 4cc5879

Browse files
committed
fix(): the last PR messed some test. Fixing that.
1 parent cd5be81 commit 4cc5879

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/components/sidenav/sidenav.spec.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ function waitOnEvent(fixture: ComponentFixture,
3737
// Wait for the animation end.
3838
let completer = PromiseWrapper.completer();
3939
let component: any = fixture.debugElement.query(by).componentInstance;
40-
component[propertyName].subscribe(completer.resolve);
40+
component[propertyName].subscribe(() => {
41+
completer.resolve();
42+
});
4143
return completer.promise;
4244
}
4345

@@ -59,16 +61,18 @@ export function main() {
5961
.then((f) => {
6062
fixture = f;
6163
testComponent = fixture.debugElement.componentInstance;
62-
64+
fixture.detectChanges();
65+
return wait(1);
66+
}).then((f) => {
6367
let openButtonElement = fixture.debugElement.query(By.css('.open'));
6468
openButtonElement.nativeElement.click();
65-
})
66-
.then((_: any) => { wait(1); })
67-
.then((_: any) => {
69+
fixture.detectChanges();
70+
return wait(1);
71+
}).then((_: any) => {
6872
expect(testComponent.openStartCount).toBe(1);
6973
expect(testComponent.openCount).toBe(0);
7074
})
71-
.then((_: any) => waitOnEvent(fixture, By.directive(MdSidenav), 'onOpen'))
75+
.then((_: any) => { return waitOnEvent(fixture, By.directive(MdSidenav), 'onOpen'); })
7276
.then((_: any) => {
7377
expect(testComponent.openStartCount).toBe(1);
7478
expect(testComponent.openCount).toBe(1);
@@ -83,6 +87,8 @@ export function main() {
8387
// Close it.
8488
let closeButtonElement = fixture.debugElement.query(By.css('.close'));
8589
closeButtonElement.nativeElement.click();
90+
fixture.detectChanges();
91+
return wait(1);
8692
})
8793
.then((_: any) => wait(1))
8894
.then((_: any) => {
@@ -91,7 +97,7 @@ export function main() {
9197
expect(testComponent.closeStartCount).toBe(1);
9298
expect(testComponent.closeCount).toBe(0);
9399
})
94-
.then((_: any) => waitOnEvent(fixture, By.directive(MdSidenav), 'onClose'))
100+
.then((_: any) => { return waitOnEvent(fixture, By.directive(MdSidenav), 'onClose'); })
95101
.then((_: any) => fixture.detectChanges())
96102
.then((_: any) => {
97103
expect(testComponent.openStartCount).toBe(1);
@@ -123,7 +129,7 @@ export function main() {
123129
promise = sidenav.open();
124130
promise.then((_: any) => called = true);
125131
})
126-
.then((_: any) => wait(1))
132+
.then((_: any) => { return wait(1); })
127133
.then((_: any) => fixture.detectChanges())
128134
.then((_: any) => {
129135
expect(called).toBe(false);
@@ -136,7 +142,7 @@ export function main() {
136142
promise = sidenav.close();
137143
promise.then((_: any) => called = true);
138144
})
139-
.then((_: any) => wait(1))
145+
.then((_: any) => { return wait(1); })
140146
.then((_: any) => fixture.detectChanges())
141147
.then((_: any) => {
142148
expect(called).toBe(false);
@@ -160,7 +166,7 @@ export function main() {
160166
promise = sidenav.open();
161167
expect(sidenav.open()).toBe(promise);
162168
})
163-
.then((_: any) => wait(1))
169+
.then((_: any) => { return wait(1); })
164170
.then((_: any) => {
165171
fixture.detectChanges();
166172
return promise;
@@ -195,10 +201,10 @@ export function main() {
195201
openCancelled = true;
196202
});
197203
})
198-
.then((_: any) => wait(1))
204+
.then((_: any) => { return wait(1); })
199205
.then((_: any) => fixture.detectChanges())
200206
// We need to wait for the browser to start the transition.
201-
.then((_: any) => wait(50))
207+
.then((_: any) => { return wait(50); })
202208
.then((_: any) => {
203209
closePromise = sidenav.close().then((_: any) => {
204210
closeCalled = true;
@@ -237,7 +243,7 @@ export function main() {
237243
/** First, open it. */
238244
openPromise = sidenav.open();
239245
})
240-
.then((_: any) => wait(1))
246+
.then((_: any) => { return wait(1); })
241247
.then((_: any) => {
242248
fixture.detectChanges();
243249
return openPromise;
@@ -251,10 +257,10 @@ export function main() {
251257
closeCancelled = true;
252258
});
253259
})
254-
.then((_: any) => wait(1))
260+
.then((_: any) => { return wait(1); })
255261
.then((_: any) => fixture.detectChanges())
256262
// We need to wait for the browser to start the transition.
257-
.then((_: any) => wait(50))
263+
.then((_: any) => { return wait(50); })
258264
.then((_: any) => {
259265
openPromise = sidenav.open().then((_: any) => {
260266
openCalled = true;

0 commit comments

Comments
 (0)