/* globals describe, it, expect, hot, expectObservable, expectSubscriptions, rxTestScheduler*/
var Rx = require('../../dist/cjs/Rx');
var Observable = Rx.Observable;

describe('Observable.prototype.observeOn()', function () {
  it('should observe on specified scheduler', function () {
    var e1 =    hot('--a--b--|');
    var expected =  '--a--b--|';
    var sub =       '^       !';

    expectObservable(e1.observeOn(rxTestScheduler)).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(sub);
  });

  it('should observe after specified delay', function () {
    var e1 =    hot('--a--b--|');
    var expected =  '-----a--b--|';
    var sub =       '^          !';

    expectObservable(e1.observeOn(rxTestScheduler, 30)).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(sub);
  });

  it('should observe when source raises error', function () {
    var e1 =    hot('--a--#');
    var expected =  '--a--#';
    var sub =       '^    !';

    expectObservable(e1.observeOn(rxTestScheduler)).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(sub);
  });

  it('should observe when source is empty', function () {
    var e1 =    hot('-----|');
    var expected =  '-----|';
    var sub =       '^    !';

    expectObservable(e1.observeOn(rxTestScheduler)).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(sub);
  });

  it('should observe when source does not complete', function () {
    var e1 =    hot('-----');
    var expected =  '-----';
    var sub =       '^    ';

    expectObservable(e1.observeOn(rxTestScheduler)).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(sub);
  });
});

@@ -1648,13 +1648,902 @@
 );%0A  %7D);
+%0A%0A  it('should allow unsubscribing early and explicitly', function () %7B%0A    var e1 =    hot('--a--b--%7C');%0A    var sub =       '%5E   !    ';%0A    var expected =  '--a--    ';%0A    var unsub =     '    !    ';%0A%0A    var result = e1.observeOn(rxTestScheduler);%0A%0A    expectObservable(result, unsub).toBe(expected);%0A    expectSubscriptions(e1.subscriptions).toBe(sub);%0A  %7D);%0A%0A  it('should not break unsubscription chains when the result is unsubscribed explicitly', function () %7B%0A    var e1 =    hot('--a--b--%7C');%0A    var sub =       '%5E   !    ';%0A    var expected =  '--a--    ';%0A    var unsub =     '    !    ';%0A%0A    var result = e1%0A      .mergeMap(function (x) %7B return Observable.of(x); %7D)%0A      .observeOn(rxTestScheduler)%0A      .mergeMap(function (x) %7B return Observable.of(x); %7D);%0A%0A    expectObservable(result, unsub).toBe(expected);%0A    expectSubscriptions(e1.subscriptions).toBe(sub);%0A  %7D);
 %0A%7D);%0A

add unsubscription-related tests