Skip to content

Commit

Permalink
style(Observable-spec): lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Jan 26, 2016
1 parent 4e75466 commit b727355
Showing 1 changed file with 60 additions and 56 deletions.
116 changes: 60 additions & 56 deletions spec/Observable-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,73 +201,77 @@ describe('Observable', function () {
});

describe('when called with an anonymous observer', function () {
it('should accept an anonymous observer with just a next function and call the next function in the context of the anonymous observer', function () {
var o = {
next: function next(x) {
expect(this).toBe(o);
expect(x).toBe(1);
}
};
Observable.of(1).subscribe(o);
});
it('should accept an anonymous observer with just a next function and call the next function in the context' +
' of the anonymous observer', function () {
var o = {
next: function next(x) {
expect(this).toBe(o);
expect(x).toBe(1);
}
};
Observable.of(1).subscribe(o);
});

it('should accept an anonymous observer with just an error function and call the error function in the context of the anonymous observer', function () {
var o = {
error: function error(err) {
expect(this).toBe(o);
expect(err).toBe('bad');
}
};
Observable.throw('bad').subscribe(o);
});
it('should accept an anonymous observer with just an error function and call the error function in the context' +
' of the anonymous observer', function () {
var o = {
error: function error(err) {
expect(this).toBe(o);
expect(err).toBe('bad');
}
};
Observable.throw('bad').subscribe(o);
});

it('should accept an anonymous observer with just a complete function and call the complete function in the context of the anonymous observer', function (done) {
var o = {
complete: function complete() {
expect(this).toBe(o);
done();
}
};
Observable.empty().subscribe(o);
});
it('should accept an anonymous observer with just a complete function and call the complete function in the' +
' context of the anonymous observer', function (done) {
var o = {
complete: function complete() {
expect(this).toBe(o);
done();
}
};
Observable.empty().subscribe(o);
});

it('should accept an anonymous observer with no functions at all', function () {
expect(function testEmptyObject() {
Observable.empty().subscribe({});
}).not.toThrow();
});

it('should not run unsubscription logic when an error is thrown sending messages synchronously to an anonymous observer', function () {
var messageError = false;
var messageErrorValue = false;
var unsubscribeCalled = false;

var o = {
next: function next(x) {
expect(this).toBe(o);
throw x;
}
};
var sub;
var source = new Observable(function (observer) {
observer.next('boo!');
return function () {
unsubscribeCalled = true;
it('should not run unsubscription logic when an error is thrown sending messages synchronously to an' +
' anonymous observer', function () {
var messageError = false;
var messageErrorValue = false;
var unsubscribeCalled = false;

var o = {
next: function next(x) {
expect(this).toBe(o);
throw x;
}
};
});

try {
sub = source.subscribe(o);
} catch (e) {
messageError = true;
messageErrorValue = e;
}
var sub;
var source = new Observable(function (observer) {
observer.next('boo!');
return function () {
unsubscribeCalled = true;
};
});

try {
sub = source.subscribe(o);
} catch (e) {
messageError = true;
messageErrorValue = e;
}

expect(sub).toBe(undefined);
expect(unsubscribeCalled).toBe(false);
expect(messageError).toBe(true);
expect(messageErrorValue).toBe('boo!');
});
expect(sub).toBe(undefined);
expect(unsubscribeCalled).toBe(false);
expect(messageError).toBe(true);
expect(messageErrorValue).toBe('boo!');
});
});
});
});
Expand Down

0 comments on commit b727355

Please sign in to comment.