fix(facade): change EventEmitter to be sync by default (#8761)
This commit is contained in:

committed by
Miško Hevery

parent
cf1122cf9e
commit
e5904f4089
@ -46,27 +46,27 @@ export function main() {
|
||||
ObservableWrapper.callComplete(emitter);
|
||||
}));
|
||||
|
||||
it("should subscribe to the wrapper asynchronously", () => {
|
||||
it("should subscribe to the wrapper synchronously", () => {
|
||||
var called = false;
|
||||
ObservableWrapper.subscribe(emitter, (value) => { called = true; });
|
||||
|
||||
ObservableWrapper.callEmit(emitter, 99);
|
||||
expect(called).toBe(false);
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
|
||||
// Makes Edge to disconnect when running the full unit test campaign
|
||||
// TODO: remove when issue is solved: https://github.com/angular/angular/issues/4756
|
||||
if (!browserDetection.isEdge) {
|
||||
it("delivers next and error events asynchronously", inject([AsyncTestCompleter], (async) => {
|
||||
it("delivers next and error events synchronously", inject([AsyncTestCompleter], (async) => {
|
||||
let log = [];
|
||||
ObservableWrapper.subscribe(emitter,
|
||||
(x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 5, 2]);
|
||||
expect(log).toEqual([1, 2]);
|
||||
},
|
||||
(err) => {
|
||||
log.push(err);
|
||||
expect(log).toEqual([1, 3, 5, 2, 4]);
|
||||
expect(log).toEqual([1, 2, 3, 4]);
|
||||
async.done();
|
||||
});
|
||||
log.push(1);
|
||||
@ -76,36 +76,39 @@ export function main() {
|
||||
log.push(5);
|
||||
}));
|
||||
|
||||
it("delivers next and complete events asynchronously",
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
it("delivers next and complete events synchronously", () => {
|
||||
let log = [];
|
||||
ObservableWrapper.subscribe(emitter,
|
||||
(x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 5, 2]);
|
||||
expect(log).toEqual([1, 2]);
|
||||
},
|
||||
null, () => {
|
||||
log.push(4);
|
||||
expect(log).toEqual([1, 3, 5, 2, 4]);
|
||||
async.done();
|
||||
});
|
||||
expect(log).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
log.push(1);
|
||||
ObservableWrapper.callEmit(emitter, 2);
|
||||
log.push(3);
|
||||
ObservableWrapper.callComplete(emitter);
|
||||
log.push(5);
|
||||
}));
|
||||
expect(log).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
}
|
||||
|
||||
it('delivers events synchronously', () => {
|
||||
var e = new EventEmitter(false);
|
||||
it('delivers events asynchronously when forced to async mode', inject([AsyncTestCompleter], (async) => {
|
||||
var e = new EventEmitter(true);
|
||||
var log = [];
|
||||
ObservableWrapper.subscribe(e, (x) => { log.push(x); });
|
||||
ObservableWrapper.subscribe(e, (x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 2]);
|
||||
async.done();
|
||||
});
|
||||
log.push(1);
|
||||
ObservableWrapper.callEmit(e, 2);
|
||||
log.push(3);
|
||||
expect(log).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
it('reports whether it has subscribers', () => {
|
||||
var e = new EventEmitter(false);
|
||||
|
Reference in New Issue
Block a user