UNPKG

@hirez_io/observer-spy

Version:

A simple little class that helps making Observable testing a breeze

49 lines 2.25 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ObserverSpyWithSubscription = exports.SubscriberSpy = void 0; var rxjs_1 = require("rxjs"); var _1 = require("."); var SubscriberSpy = /** @class */ (function (_super) { __extends(SubscriberSpy, _super); function SubscriberSpy(observableUnderTest, config) { var _this = _super.call(this, config) || this; _this.subscription = new rxjs_1.Subscription(); _this.subscription.add(observableUnderTest.subscribe(_this)); return _this; } SubscriberSpy.prototype.unsubscribe = function () { this.subscription.unsubscribe(); }; return SubscriberSpy; }(_1.ObserverSpy)); exports.SubscriberSpy = SubscriberSpy; /* istanbul ignore next */ // tslint:disable-next-line:max-classes-per-file var ObserverSpyWithSubscription = /** @class */ (function (_super) { __extends(ObserverSpyWithSubscription, _super); function ObserverSpyWithSubscription(observableUnderTest) { var _this = this; // tslint:disable-next-line:no-console console.warn('ObserverSpyWithSubscription is deprecated and will be removed in the next version, please use "SubscriberSpy" instead.'); _this = _super.call(this, observableUnderTest) || this; return _this; } return ObserverSpyWithSubscription; }(SubscriberSpy)); exports.ObserverSpyWithSubscription = ObserverSpyWithSubscription; //# sourceMappingURL=subscriber-spy.js.map