<commit_before>/* 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);
  });
});<commit_msg>test(defaultIfEmpty): add subscription assertions to defaultIfEmpty tests<commit_after>/* globals describe, it, expect, expectObservable, expectSubscriptions, cold, 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 =  cold('|');
    var e1subs =   '(^!)';
    var expected = '(x|)';

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

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

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

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

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

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

    expectObservable(e1.defaultIfEmpty()).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });

  it('should error if the Observable errors', function () {
    var e1 =  cold('#');
    var e1subs =   '(^!)';
    var expected = '#';

    expectObservable(e1.defaultIfEmpty('x')).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });
});
{'fraction_non_alphanumeric': 0.1777922500814067, 'fraction_numerical': 0.011396939107782481, 'mean_word_length': 3.5309734513274336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6872213', 'n_tokens_mistral': 986, 'n_tokens_neox': 961, 'n_words': 234}