All files / src/testing-helpers/marble-testing/helpers test-helper2.hlpr.ts

60.38% Statements 32/53
16.67% Branches 1/6
40% Functions 6/15
60.38% Lines 32/53
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 1041x       1x         1x 1x   1x 1x   1x 1x 1x 1x 1x 1x 1x     11x     1x   1x 30x 30x 30x 30x 30x             1x       1x   1x                       1x 471x     1x 471x     1x 1x                           1x     1x                                    
import { toDeepEqualMatcher } from '../../jasmine-matchers/to-deep-equal.matcher';
 
declare var global, require, beforeEach, afterEach, jasmine, Symbol;
 
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
 
import {isEqual} from 'lodash';
import * as _ from 'lodash';
 
const root = require('rxjs/util/root').root;
import {TestScheduler} from 'rxjs/testing/TestScheduler';
 
import marbleHelpers from './marble-testing2.hlpr';
import arrayObjectHelpers from './array2Object.helper.hlpr';
 
global.rxTestScheduler = null;
global.cold = marbleHelpers.cold;
global.hot = marbleHelpers.hot;
global.expectObservable = marbleHelpers.expectObservable;
global.expectSubscriptions = marbleHelpers.expectSubscriptions;
global.array2Object = arrayObjectHelpers.array2Object;
global.object2Array = arrayObjectHelpers.object2Array;
 
function assertDeepEqual(actual, expected) {
  (<any> expect(actual)).toDeepEqual(expected);
}
 
const glit = global.it;
 
global.it = function(description, cb, timeout) {
  Eif (cb.length === 0) {
    glit(description, function() {
      global.rxTestScheduler = new TestScheduler(assertDeepEqual);
      cb();
      global.rxTestScheduler.flush();
    });
  } else {
    glit.apply(this, arguments);
  }
};
 
global.it.asDiagram = function() {
  return global.it;
};
 
const glfit = global.fit;
 
global.fit = function(description, cb, timeout) {
  if (cb.length === 0) {
    glfit(description, function() {
      global.rxTestScheduler = new TestScheduler(assertDeepEqual);
      cb();
      global.rxTestScheduler.flush();
    });
  } else {
    glfit.apply(this, arguments);
  }
};
 
beforeEach(function() {
  jasmine.addMatchers(toDeepEqualMatcher);
});
 
afterEach(function() {
  global.rxTestScheduler = null;
});
 
(function() {
  Object.defineProperty(Error.prototype, 'toJSON', {
    value: function() {
      const alt = {};
 
      Object.getOwnPropertyNames(this).forEach(function(key) {
        if (key !== 'stack') {
          alt[key] = this[key];
        }
      }, this);
      return alt;
    },
    configurable: true
  });
 
  global.__root__ = root;
})();
 
global.lowerCaseO = function lowerCaseO() {
  const values = [].slice.apply(arguments);
 
  const o = {
    subscribe: function(observer) {
      values.forEach(function(v) {
        observer.next(v);
      });
      observer.complete();
    }
  };
 
  o[(<any>Symbol).observable] = function() {
    return this;
  };
 
  return o;
};