This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

20
node_modules/rxjs/testing/ColdObservable.d.ts generated vendored Normal file
View File

@ -0,0 +1,20 @@
import { Observable } from '../Observable';
import { Scheduler } from '../Scheduler';
import { TestMessage } from './TestMessage';
import { SubscriptionLog } from './SubscriptionLog';
import { SubscriptionLoggable } from './SubscriptionLoggable';
import { Subscriber } from '../Subscriber';
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export declare class ColdObservable<T> extends Observable<T> implements SubscriptionLoggable {
messages: TestMessage[];
subscriptions: SubscriptionLog[];
scheduler: Scheduler;
logSubscribedFrame: () => number;
logUnsubscribedFrame: (index: number) => void;
constructor(messages: TestMessage[], scheduler: Scheduler);
scheduleMessages(subscriber: Subscriber<any>): void;
}

46
node_modules/rxjs/testing/ColdObservable.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = require('../Observable');
var Subscription_1 = require('../Subscription');
var SubscriptionLoggable_1 = require('./SubscriptionLoggable');
var applyMixins_1 = require('../util/applyMixins');
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var ColdObservable = (function (_super) {
__extends(ColdObservable, _super);
function ColdObservable(messages, scheduler) {
_super.call(this, function (subscriber) {
var observable = this;
var index = observable.logSubscribedFrame();
subscriber.add(new Subscription_1.Subscription(function () {
observable.logUnsubscribedFrame(index);
}));
observable.scheduleMessages(subscriber);
return subscriber;
});
this.messages = messages;
this.subscriptions = [];
this.scheduler = scheduler;
}
ColdObservable.prototype.scheduleMessages = function (subscriber) {
var messagesLength = this.messages.length;
for (var i = 0; i < messagesLength; i++) {
var message = this.messages[i];
subscriber.add(this.scheduler.schedule(function (_a) {
var message = _a.message, subscriber = _a.subscriber;
message.notification.observe(subscriber);
}, message.frame, { message: message, subscriber: subscriber }));
}
};
return ColdObservable;
}(Observable_1.Observable));
exports.ColdObservable = ColdObservable;
applyMixins_1.applyMixins(ColdObservable, [SubscriptionLoggable_1.SubscriptionLoggable]);
//# sourceMappingURL=ColdObservable.js.map

1
node_modules/rxjs/testing/ColdObservable.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"ColdObservable.js","sourceRoot":"","sources":["../../src/testing/ColdObservable.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA2B,eAAe,CAAC,CAAA;AAC3C,6BAA6B,iBAAiB,CAAC,CAAA;AAI/C,qCAAqC,wBAAwB,CAAC,CAAA;AAC9D,4BAA4B,qBAAqB,CAAC,CAAA;AAGlD;;;;GAIG;AACH;IAAuC,kCAAa;IAMlD,wBAAmB,QAAuB,EAC9B,SAAoB;QAC9B,kBAAM,UAAmC,UAA2B;YAClE,IAAM,UAAU,GAAsB,IAAI,CAAC;YAC3C,IAAM,KAAK,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;YAC9C,UAAU,CAAC,GAAG,CAAC,IAAI,2BAAY,CAAC;gBAC9B,UAAU,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC,CAAC;YACJ,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACxC,MAAM,CAAC,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;QAVc,aAAQ,GAAR,QAAQ,CAAe;QALnC,kBAAa,GAAsB,EAAE,CAAC;QAgB3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,yCAAgB,GAAhB,UAAiB,UAA2B;QAC1C,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACjC,UAAU,CAAC,GAAG,CACZ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAC,EAAqB;oBAApB,oBAAO,EAAE,0BAAU;gBAAQ,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAAC,CAAC,EAC9F,OAAO,CAAC,KAAK,EACb,EAAC,gBAAO,EAAE,sBAAU,EAAC,CAAC,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;IACH,qBAAC;AAAD,CAAC,AA/BD,CAAuC,uBAAU,GA+BhD;AA/BY,sBAAc,iBA+B1B,CAAA;AACD,yBAAW,CAAC,cAAc,EAAE,CAAC,2CAAoB,CAAC,CAAC,CAAC","sourcesContent":["import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nimport { Scheduler } from '../Scheduler';\nimport { TestMessage } from './TestMessage';\nimport { SubscriptionLog } from './SubscriptionLog';\nimport { SubscriptionLoggable } from './SubscriptionLoggable';\nimport { applyMixins } from '../util/applyMixins';\nimport { Subscriber } from '../Subscriber';\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nexport class ColdObservable<T> extends Observable<T> implements SubscriptionLoggable {\n public subscriptions: SubscriptionLog[] = [];\n scheduler: Scheduler;\n logSubscribedFrame: () => number;\n logUnsubscribedFrame: (index: number) => void;\n\n constructor(public messages: TestMessage[],\n scheduler: Scheduler) {\n super(function (this: ColdObservable<T>, subscriber: Subscriber<any>) {\n const observable: ColdObservable<T> = this;\n const index = observable.logSubscribedFrame();\n subscriber.add(new Subscription(() => {\n observable.logUnsubscribedFrame(index);\n }));\n observable.scheduleMessages(subscriber);\n return subscriber;\n });\n this.scheduler = scheduler;\n }\n\n scheduleMessages(subscriber: Subscriber<any>) {\n const messagesLength = this.messages.length;\n for (let i = 0; i < messagesLength; i++) {\n const message = this.messages[i];\n subscriber.add(\n this.scheduler.schedule(({message, subscriber}) => { message.notification.observe(subscriber); },\n message.frame,\n {message, subscriber})\n );\n }\n }\n}\napplyMixins(ColdObservable, [SubscriptionLoggable]);\n"]}

22
node_modules/rxjs/testing/HotObservable.d.ts generated vendored Normal file
View File

@ -0,0 +1,22 @@
import { Subject } from '../Subject';
import { Subscriber } from '../Subscriber';
import { Subscription } from '../Subscription';
import { Scheduler } from '../Scheduler';
import { TestMessage } from './TestMessage';
import { SubscriptionLog } from './SubscriptionLog';
import { SubscriptionLoggable } from './SubscriptionLoggable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export declare class HotObservable<T> extends Subject<T> implements SubscriptionLoggable {
messages: TestMessage[];
subscriptions: SubscriptionLog[];
scheduler: Scheduler;
logSubscribedFrame: () => number;
logUnsubscribedFrame: (index: number) => void;
constructor(messages: TestMessage[], scheduler: Scheduler);
/** @deprecated internal use only */ _subscribe(subscriber: Subscriber<any>): Subscription;
setup(): void;
}

48
node_modules/rxjs/testing/HotObservable.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subject_1 = require('../Subject');
var Subscription_1 = require('../Subscription');
var SubscriptionLoggable_1 = require('./SubscriptionLoggable');
var applyMixins_1 = require('../util/applyMixins');
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var HotObservable = (function (_super) {
__extends(HotObservable, _super);
function HotObservable(messages, scheduler) {
_super.call(this);
this.messages = messages;
this.subscriptions = [];
this.scheduler = scheduler;
}
/** @deprecated internal use only */ HotObservable.prototype._subscribe = function (subscriber) {
var subject = this;
var index = subject.logSubscribedFrame();
subscriber.add(new Subscription_1.Subscription(function () {
subject.logUnsubscribedFrame(index);
}));
return _super.prototype._subscribe.call(this, subscriber);
};
HotObservable.prototype.setup = function () {
var subject = this;
var messagesLength = subject.messages.length;
/* tslint:disable:no-var-keyword */
for (var i = 0; i < messagesLength; i++) {
(function () {
var message = subject.messages[i];
/* tslint:enable */
subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
})();
}
};
return HotObservable;
}(Subject_1.Subject));
exports.HotObservable = HotObservable;
applyMixins_1.applyMixins(HotObservable, [SubscriptionLoggable_1.SubscriptionLoggable]);
//# sourceMappingURL=HotObservable.js.map

1
node_modules/rxjs/testing/HotObservable.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"HotObservable.js","sourceRoot":"","sources":["../../src/testing/HotObservable.ts"],"names":[],"mappings":";;;;;;AAAA,wBAAwB,YAAY,CAAC,CAAA;AAErC,6BAA6B,iBAAiB,CAAC,CAAA;AAI/C,qCAAqC,wBAAwB,CAAC,CAAA;AAC9D,4BAA4B,qBAAqB,CAAC,CAAA;AAElD;;;;GAIG;AACH;IAAsC,iCAAU;IAM9C,uBAAmB,QAAuB,EAC9B,SAAoB;QAC9B,iBAAO,CAAC;QAFS,aAAQ,GAAR,QAAQ,CAAe;QALnC,kBAAa,GAAsB,EAAE,CAAC;QAQ3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,oCAAoC,CAAC,kCAAU,GAAV,UAAW,UAA2B;QACzE,IAAM,OAAO,GAAqB,IAAI,CAAC;QACvC,IAAM,KAAK,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC3C,UAAU,CAAC,GAAG,CAAC,IAAI,2BAAY,CAAC;YAC9B,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,gBAAK,CAAC,UAAU,YAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,6BAAK,GAAL;QACE,IAAM,OAAO,GAAG,IAAI,CAAC;QACrB,IAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC/C,mCAAmC;QACnC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,CAAC;gBACC,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACvC,mBAAmB;gBACd,OAAO,CAAC,SAAS,CAAC,QAAQ,CACxB,cAAQ,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAChD,OAAO,CAAC,KAAK,CACd,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AApCD,CAAsC,iBAAO,GAoC5C;AApCY,qBAAa,gBAoCzB,CAAA;AACD,yBAAW,CAAC,aAAa,EAAE,CAAC,2CAAoB,CAAC,CAAC,CAAC","sourcesContent":["import { Subject } from '../Subject';\nimport { Subscriber } from '../Subscriber';\nimport { Subscription } from '../Subscription';\nimport { Scheduler } from '../Scheduler';\nimport { TestMessage } from './TestMessage';\nimport { SubscriptionLog } from './SubscriptionLog';\nimport { SubscriptionLoggable } from './SubscriptionLoggable';\nimport { applyMixins } from '../util/applyMixins';\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nexport class HotObservable<T> extends Subject<T> implements SubscriptionLoggable {\n public subscriptions: SubscriptionLog[] = [];\n scheduler: Scheduler;\n logSubscribedFrame: () => number;\n logUnsubscribedFrame: (index: number) => void;\n\n constructor(public messages: TestMessage[],\n scheduler: Scheduler) {\n super();\n this.scheduler = scheduler;\n }\n\n /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<any>): Subscription {\n const subject: HotObservable<T> = this;\n const index = subject.logSubscribedFrame();\n subscriber.add(new Subscription(() => {\n subject.logUnsubscribedFrame(index);\n }));\n return super._subscribe(subscriber);\n }\n\n setup() {\n const subject = this;\n const messagesLength = subject.messages.length;\n /* tslint:disable:no-var-keyword */\n for (var i = 0; i < messagesLength; i++) {\n (() => {\n var message = subject.messages[i];\n /* tslint:enable */\n subject.scheduler.schedule(\n () => { message.notification.observe(subject); },\n message.frame\n );\n })();\n }\n }\n}\napplyMixins(HotObservable, [SubscriptionLoggable]);\n"]}

5
node_modules/rxjs/testing/SubscriptionLog.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
export declare class SubscriptionLog {
subscribedFrame: number;
unsubscribedFrame: number;
constructor(subscribedFrame: number, unsubscribedFrame?: number);
}

11
node_modules/rxjs/testing/SubscriptionLog.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
"use strict";
var SubscriptionLog = (function () {
function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
this.subscribedFrame = subscribedFrame;
this.unsubscribedFrame = unsubscribedFrame;
}
return SubscriptionLog;
}());
exports.SubscriptionLog = SubscriptionLog;
//# sourceMappingURL=SubscriptionLog.js.map

1
node_modules/rxjs/testing/SubscriptionLog.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"SubscriptionLog.js","sourceRoot":"","sources":["../../src/testing/SubscriptionLog.ts"],"names":[],"mappings":";AAAA;IACE,yBAAmB,eAAuB,EACvB,iBAAoD;QAA3D,iCAA2D,GAA3D,oBAAmC,MAAM,CAAC,iBAAiB;QADpD,oBAAe,GAAf,eAAe,CAAQ;QACvB,sBAAiB,GAAjB,iBAAiB,CAAmC;IACvE,CAAC;IACH,sBAAC;AAAD,CAAC,AAJD,IAIC;AAJY,uBAAe,kBAI3B,CAAA","sourcesContent":["export class SubscriptionLog {\n constructor(public subscribedFrame: number,\n public unsubscribedFrame: number = Number.POSITIVE_INFINITY) {\n }\n}"]}

8
node_modules/rxjs/testing/SubscriptionLoggable.d.ts generated vendored Normal file
View File

@ -0,0 +1,8 @@
import { Scheduler } from '../Scheduler';
import { SubscriptionLog } from './SubscriptionLog';
export declare class SubscriptionLoggable {
subscriptions: SubscriptionLog[];
scheduler: Scheduler;
logSubscribedFrame(): number;
logUnsubscribedFrame(index: number): void;
}

19
node_modules/rxjs/testing/SubscriptionLoggable.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var SubscriptionLog_1 = require('./SubscriptionLog');
var SubscriptionLoggable = (function () {
function SubscriptionLoggable() {
this.subscriptions = [];
}
SubscriptionLoggable.prototype.logSubscribedFrame = function () {
this.subscriptions.push(new SubscriptionLog_1.SubscriptionLog(this.scheduler.now()));
return this.subscriptions.length - 1;
};
SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
var subscriptionLogs = this.subscriptions;
var oldSubscriptionLog = subscriptionLogs[index];
subscriptionLogs[index] = new SubscriptionLog_1.SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
};
return SubscriptionLoggable;
}());
exports.SubscriptionLoggable = SubscriptionLoggable;
//# sourceMappingURL=SubscriptionLoggable.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"SubscriptionLoggable.js","sourceRoot":"","sources":["../../src/testing/SubscriptionLoggable.ts"],"names":[],"mappings":";AACA,gCAAgC,mBAAmB,CAAC,CAAA;AAEpD;IAAA;QACS,kBAAa,GAAsB,EAAE,CAAC;IAgB/C,CAAC;IAbC,iDAAkB,GAAlB;QACE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,iCAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,mDAAoB,GAApB,UAAqB,KAAa;QAChC,IAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC;QAC5C,IAAM,kBAAkB,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACnD,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,iCAAe,CAC3C,kBAAkB,CAAC,eAAe,EAClC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACrB,CAAC;IACJ,CAAC;IACH,2BAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,4BAAoB,uBAiBhC,CAAA","sourcesContent":["import { Scheduler } from '../Scheduler';\nimport { SubscriptionLog } from './SubscriptionLog';\n\nexport class SubscriptionLoggable {\n public subscriptions: SubscriptionLog[] = [];\n scheduler: Scheduler;\n\n logSubscribedFrame(): number {\n this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));\n return this.subscriptions.length - 1;\n }\n\n logUnsubscribedFrame(index: number) {\n const subscriptionLogs = this.subscriptions;\n const oldSubscriptionLog = subscriptionLogs[index];\n subscriptionLogs[index] = new SubscriptionLog(\n oldSubscriptionLog.subscribedFrame,\n this.scheduler.now()\n );\n }\n}\n"]}

5
node_modules/rxjs/testing/TestMessage.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import { Notification } from '../Notification';
export interface TestMessage {
frame: number;
notification: Notification<any>;
}

2
node_modules/rxjs/testing/TestMessage.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=TestMessage.js.map

1
node_modules/rxjs/testing/TestMessage.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"TestMessage.js","sourceRoot":"","sources":["../../src/testing/TestMessage.ts"],"names":[],"mappings":"","sourcesContent":["import { Notification } from '../Notification';\n\nexport interface TestMessage {\n frame: number;\n notification: Notification<any>;\n}"]}

28
node_modules/rxjs/testing/TestScheduler.d.ts generated vendored Normal file
View File

@ -0,0 +1,28 @@
import { Observable } from '../Observable';
import { ColdObservable } from './ColdObservable';
import { HotObservable } from './HotObservable';
import { TestMessage } from './TestMessage';
import { SubscriptionLog } from './SubscriptionLog';
import { VirtualTimeScheduler } from '../scheduler/VirtualTimeScheduler';
export declare type observableToBeFn = (marbles: string, values?: any, errorValue?: any) => void;
export declare type subscriptionLogsToBeFn = (marbles: string | string[]) => void;
export declare class TestScheduler extends VirtualTimeScheduler {
assertDeepEqual: (actual: any, expected: any) => boolean | void;
private hotObservables;
private coldObservables;
private flushTests;
constructor(assertDeepEqual: (actual: any, expected: any) => boolean | void);
createTime(marbles: string): number;
createColdObservable<T>(marbles: string, values?: any, error?: any): ColdObservable<T>;
createHotObservable<T>(marbles: string, values?: any, error?: any): HotObservable<T>;
private materializeInnerObservable(observable, outerFrame);
expectObservable(observable: Observable<any>, unsubscriptionMarbles?: string): ({
toBe: observableToBeFn;
});
expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({
toBe: subscriptionLogsToBeFn;
});
flush(): void;
static parseMarblesAsSubscriptions(marbles: string): SubscriptionLog;
static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables?: boolean): TestMessage[];
}

223
node_modules/rxjs/testing/TestScheduler.js generated vendored Normal file
View File

@ -0,0 +1,223 @@
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = require('../Observable');
var Notification_1 = require('../Notification');
var ColdObservable_1 = require('./ColdObservable');
var HotObservable_1 = require('./HotObservable');
var SubscriptionLog_1 = require('./SubscriptionLog');
var VirtualTimeScheduler_1 = require('../scheduler/VirtualTimeScheduler');
var defaultMaxFrame = 750;
var TestScheduler = (function (_super) {
__extends(TestScheduler, _super);
function TestScheduler(assertDeepEqual) {
_super.call(this, VirtualTimeScheduler_1.VirtualAction, defaultMaxFrame);
this.assertDeepEqual = assertDeepEqual;
this.hotObservables = [];
this.coldObservables = [];
this.flushTests = [];
}
TestScheduler.prototype.createTime = function (marbles) {
var indexOf = marbles.indexOf('|');
if (indexOf === -1) {
throw new Error('marble diagram for time should have a completion marker "|"');
}
return indexOf * TestScheduler.frameTimeFactor;
};
TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
if (marbles.indexOf('^') !== -1) {
throw new Error('cold observable cannot have subscription offset "^"');
}
if (marbles.indexOf('!') !== -1) {
throw new Error('cold observable cannot have unsubscription marker "!"');
}
var messages = TestScheduler.parseMarbles(marbles, values, error);
var cold = new ColdObservable_1.ColdObservable(messages, this);
this.coldObservables.push(cold);
return cold;
};
TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
if (marbles.indexOf('!') !== -1) {
throw new Error('hot observable cannot have unsubscription marker "!"');
}
var messages = TestScheduler.parseMarbles(marbles, values, error);
var subject = new HotObservable_1.HotObservable(messages, this);
this.hotObservables.push(subject);
return subject;
};
TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
var _this = this;
var messages = [];
observable.subscribe(function (value) {
messages.push({ frame: _this.frame - outerFrame, notification: Notification_1.Notification.createNext(value) });
}, function (err) {
messages.push({ frame: _this.frame - outerFrame, notification: Notification_1.Notification.createError(err) });
}, function () {
messages.push({ frame: _this.frame - outerFrame, notification: Notification_1.Notification.createComplete() });
});
return messages;
};
TestScheduler.prototype.expectObservable = function (observable, unsubscriptionMarbles) {
var _this = this;
if (unsubscriptionMarbles === void 0) { unsubscriptionMarbles = null; }
var actual = [];
var flushTest = { actual: actual, ready: false };
var unsubscriptionFrame = TestScheduler
.parseMarblesAsSubscriptions(unsubscriptionMarbles).unsubscribedFrame;
var subscription;
this.schedule(function () {
subscription = observable.subscribe(function (x) {
var value = x;
// Support Observable-of-Observables
if (x instanceof Observable_1.Observable) {
value = _this.materializeInnerObservable(value, _this.frame);
}
actual.push({ frame: _this.frame, notification: Notification_1.Notification.createNext(value) });
}, function (err) {
actual.push({ frame: _this.frame, notification: Notification_1.Notification.createError(err) });
}, function () {
actual.push({ frame: _this.frame, notification: Notification_1.Notification.createComplete() });
});
}, 0);
if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
}
this.flushTests.push(flushTest);
return {
toBe: function (marbles, values, errorValue) {
flushTest.ready = true;
flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true);
}
};
};
TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
var flushTest = { actual: actualSubscriptionLogs, ready: false };
this.flushTests.push(flushTest);
return {
toBe: function (marbles) {
var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
flushTest.ready = true;
flushTest.expected = marblesArray.map(function (marbles) {
return TestScheduler.parseMarblesAsSubscriptions(marbles);
});
}
};
};
TestScheduler.prototype.flush = function () {
var hotObservables = this.hotObservables;
while (hotObservables.length > 0) {
hotObservables.shift().setup();
}
_super.prototype.flush.call(this);
var readyFlushTests = this.flushTests.filter(function (test) { return test.ready; });
while (readyFlushTests.length > 0) {
var test = readyFlushTests.shift();
this.assertDeepEqual(test.actual, test.expected);
}
};
TestScheduler.parseMarblesAsSubscriptions = function (marbles) {
if (typeof marbles !== 'string') {
return new SubscriptionLog_1.SubscriptionLog(Number.POSITIVE_INFINITY);
}
var len = marbles.length;
var groupStart = -1;
var subscriptionFrame = Number.POSITIVE_INFINITY;
var unsubscriptionFrame = Number.POSITIVE_INFINITY;
for (var i = 0; i < len; i++) {
var frame = i * this.frameTimeFactor;
var c = marbles[i];
switch (c) {
case '-':
case ' ':
break;
case '(':
groupStart = frame;
break;
case ')':
groupStart = -1;
break;
case '^':
if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
throw new Error('found a second subscription point \'^\' in a ' +
'subscription marble diagram. There can only be one.');
}
subscriptionFrame = groupStart > -1 ? groupStart : frame;
break;
case '!':
if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
throw new Error('found a second subscription point \'^\' in a ' +
'subscription marble diagram. There can only be one.');
}
unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
break;
default:
throw new Error('there can only be \'^\' and \'!\' markers in a ' +
'subscription marble diagram. Found instead \'' + c + '\'.');
}
}
if (unsubscriptionFrame < 0) {
return new SubscriptionLog_1.SubscriptionLog(subscriptionFrame);
}
else {
return new SubscriptionLog_1.SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
}
};
TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables) {
if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
if (marbles.indexOf('!') !== -1) {
throw new Error('conventional marble diagrams cannot have the ' +
'unsubscription marker "!"');
}
var len = marbles.length;
var testMessages = [];
var subIndex = marbles.indexOf('^');
var frameOffset = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
var getValue = typeof values !== 'object' ?
function (x) { return x; } :
function (x) {
// Support Observable-of-Observables
if (materializeInnerObservables && values[x] instanceof ColdObservable_1.ColdObservable) {
return values[x].messages;
}
return values[x];
};
var groupStart = -1;
for (var i = 0; i < len; i++) {
var frame = i * this.frameTimeFactor + frameOffset;
var notification = void 0;
var c = marbles[i];
switch (c) {
case '-':
case ' ':
break;
case '(':
groupStart = frame;
break;
case ')':
groupStart = -1;
break;
case '|':
notification = Notification_1.Notification.createComplete();
break;
case '^':
break;
case '#':
notification = Notification_1.Notification.createError(errorValue || 'error');
break;
default:
notification = Notification_1.Notification.createNext(getValue(c));
break;
}
if (notification) {
testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
}
}
return testMessages;
};
return TestScheduler;
}(VirtualTimeScheduler_1.VirtualTimeScheduler));
exports.TestScheduler = TestScheduler;
//# sourceMappingURL=TestScheduler.js.map

1
node_modules/rxjs/testing/TestScheduler.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long