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

describe('Observable.prototype.findIndex()', function () {
  function truePredicate(x) {
    return true;
  }

  it('should not emit if source does not emit', function () {
    var source = hot('-');
    var expected =   '-';

    expectObservable(source.findIndex(truePredicate)).toBe(expected);
  });

  it('should return negative index if source is empty to match predicate', function () {
    var expected = '(x|)';

    expectObservable(Observable.empty().findIndex(truePredicate)).toBe(expected, {x: -1});
  });

  it('should return index of element from source emits single element', function () {
    var sourceValue = 1;
    var source = hot('--a--|', { a: sourceValue });
    var expected =   '--(x|)';

    var predicate = function (value) {
      return value === sourceValue;
    };

    expectObservable(source.findIndex(predicate)).toBe(expected, { x: 0 });
  });

  it('should return negative index if element does not match with predicate', function () {
    var source = hot('--a--b--c--|');
    var expected =   '-----------(x|)';

    var predicate = function (value) {
      return value === 'z';
    };

    expectObservable(source.findIndex(predicate)).toBe(expected, { x: -1 });
  });

  it('should raise if source raise error while element does not match with predicate', function () {
    var source = hot('--a--b--#');
    var expected =   '--------#';

    var predicate = function (value) {
      return value === 'z';
    };

    expectObservable(source.findIndex(predicate)).toBe(expected);
  });

  it('should raise error if predicate throws error', function () {
    var source = hot('--a--b--c--|');
    var expected =   '--#';

    var predicate = function (value) {
      throw 'error';
    };

    expectObservable(source.findIndex(predicate)).toBe(expected);
  });
});<commit_msg>test(findIndex): add subscription assertions for findIndex tests<commit_after>/* globals describe, it, expect, hot, cold, expectObservable, expectSubscriptions */
var Rx = require('../../dist/cjs/Rx.KitchenSink');
var Observable = Rx.Observable;

describe('Observable.prototype.findIndex()', function () {
  function truePredicate(x) {
    return true;
  }

  it('should not emit if source does not emit', function () {
    var source = hot('-');
    var subs =       '^';
    var expected =   '-';

    expectObservable(source.findIndex(truePredicate)).toBe(expected);
    expectSubscriptions(source.subscriptions).toBe(subs);
  });

  it('should return negative index if source is empty to match predicate', function () {
    var source = cold('|');
    var subs =        '(^!)';
    var expected =    '(x|)';

    var result = source.findIndex(truePredicate);

    expectObservable(result).toBe(expected, {x: -1});
    expectSubscriptions(source.subscriptions).toBe(subs);
  });

  it('should return index of element from source emits single element', function () {
    var sourceValue = 1;
    var source = hot('--a--|', { a: sourceValue });
    var subs =       '^ !   ';
    var expected =   '--(x|)';

    var predicate = function (value) {
      return value === sourceValue;
    };

    expectObservable(source.findIndex(predicate)).toBe(expected, { x: 0 });
    expectSubscriptions(source.subscriptions).toBe(subs);
  });

  it('should return negative index if element does not match with predicate', function () {
    var source = hot('--a--b--c--|');
    var subs =       '^          !';
    var expected =   '-----------(x|)';

    var predicate = function (value) {
      return value === 'z';
    };

    expectObservable(source.findIndex(predicate)).toBe(expected, { x: -1 });
    expectSubscriptions(source.subscriptions).toBe(subs);
  });

  it('should raise if source raise error while element does not match with predicate', function () {
    var source = hot('--a--b--#');
    var subs =       '^       !';
    var expected =   '--------#';

    var predicate = function (value) {
      return value === 'z';
    };

    expectObservable(source.findIndex(predicate)).toBe(expected);
    expectSubscriptions(source.subscriptions).toBe(subs);
  });

  it('should raise error if predicate throws error', function () {
    var source = hot('--a--b--c--|');
    var subs =       '^ !';
    var expected =   '--#';

    var predicate = function (value) {
      throw 'error';
    };

    expectObservable(source.findIndex(predicate)).toBe(expected);
    expectSubscriptions(source.subscriptions).toBe(subs);
  });
});
{'fraction_non_alphanumeric': 0.17060994139353158, 'fraction_numerical': 0.0017364879531148252, 'mean_word_length': 3.0034752389226758, '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': '7199212', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1325, 'n_words': 350}