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

describe('Observable.prototype.defaultIfEmpty()', function () {
  it('should return the argument if Observable is empty', function () {
    var e1 = Observable.empty();
    var expected = '(x|)';

    expectObservable(e1.defaultIfEmpty('x')).toBe(expected);
  });

  it('should return null if the Observable is empty and no arguments', function () {
    var e1 = Observable.empty();
    var expected = '(x|)';

    expectObservable(e1.defaultIfEmpty()).toBe(expected, { x: null });
  });

  it('should return the Observable if not empty with a default value', function () {
    var e1 =   hot('--a--b--|');
    var expected = '--a--b--|';

    expectObservable(e1.defaultIfEmpty('x')).toBe(expected);
  });

  it('should return the Observable if not empty with no default value', function () {
    var e1 =   hot('--a--b--|');
    var expected = '--a--b--|';

    expectObservable(e1.defaultIfEmpty()).toBe(expected);
  });

  it('should error if the Observable errors', function () {
    var error = 'error';
    var e1 = Observable.throw(error);
    var expected = '#';

    expectObservable(e1.defaultIfEmpty('x')).toBe(expected, null, error);
  });
});
@@ -43,16 +43,43 @@
 ervable,
+ expectSubscriptions, cold,
  hot */%0A
@@ -299,34 +299,53 @@
 ar e1 = 
-Observable.empty()
+ cold('%7C');%0A    var e1subs =   '(%5E!)'
 ;%0A    va
@@ -419,32 +419,88 @@
 toBe(expected);%0A
+    expectSubscriptions(e1.subscriptions).toBe(e1subs);%0A
   %7D);%0A%0A  it('sho
@@ -592,26 +592,45 @@
 1 = 
-Observable.empty()
+ cold('%7C');%0A    var e1subs =   '(%5E!)'
 ;%0A  
@@ -726,16 +726,72 @@
 ull %7D);%0A
+    expectSubscriptions(e1.subscriptions).toBe(e1subs);%0A
   %7D);%0A%0A 
@@ -899,32 +899,64 @@
 t('--a--b--%7C');%0A
+    var e1subs =   '%5E       !';%0A
     var expected
@@ -1025,32 +1025,88 @@
 toBe(expected);%0A
+    expectSubscriptions(e1.subscriptions).toBe(e1subs);%0A
   %7D);%0A%0A  it('sho
@@ -1207,32 +1207,64 @@
 t('--a--b--%7C');%0A
+    var e1subs =   '%5E       !';%0A
     var expected
@@ -1338,16 +1338,72 @@
 ected);%0A
+    expectSubscriptions(e1.subscriptions).toBe(e1subs);%0A
   %7D);%0A%0A 
@@ -1474,60 +1474,49 @@
 ar e
-rror = 'error';%0A    var e1 = Observable.throw(error)
+1 =  cold('#');%0A    var e1subs =   '(%5E!)'
 ;%0A  
@@ -1600,21 +1600,64 @@
 cted
-, null, error
+);%0A    expectSubscriptions(e1.subscriptions).toBe(e1subs
 );%0A 

add subscription assertions to defaultIfEmpty tests