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AAK,CAAC;oBACnB,KAAK,CAAC;gBACR,KAAK,GAAG;oBACN,UAAU,GAAG,CAAC,CAAC,CAAC;oBAChB,KAAK,CAAC;gBACR,KAAK,GAAG;oBACN,YAAY,GAAG,2BAAY,CAAC,cAAc,EAAE,CAAC;oBAC7C,KAAK,CAAC;gBACR,KAAK,GAAG;oBACN,KAAK,CAAC;gBACR,KAAK,GAAG;oBACN,YAAY,GAAG,2BAAY,CAAC,WAAW,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC;oBAC/D,KAAK,CAAC;gBACR;oBACE,YAAY,GAAG,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBACpD,KAAK,CAAC;YACV,CAAC;YAED,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;gBACjB,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC,GAAG,UAAU,GAAG,KAAK,EAAE,0BAAY,EAAE,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;QACD,MAAM,CAAC,YAAY,CAAC;IACtB,CAAC;IACH,oBAAC;AAAD,CAAC,AA/ND,CAAmC,2CAAoB,GA+NtD;AA/NY,qBAAa,gBA+NzB,CAAA","sourcesContent":["import { Observable } from '../Observable';\nimport { Notification } from '../Notification';\nimport { ColdObservable } from './ColdObservable';\nimport { HotObservable } from './HotObservable';\nimport { TestMessage } from './TestMessage';\nimport { SubscriptionLog } from './SubscriptionLog';\nimport { Subscription } from '../Subscription';\nimport { VirtualTimeScheduler, VirtualAction } from '../scheduler/VirtualTimeScheduler';\n\nconst defaultMaxFrame: number = 750;\n\ninterface FlushableTest {\n ready: boolean;\n actual?: any[];\n expected?: any[];\n}\n\nexport type observableToBeFn = (marbles: string, values?: any, errorValue?: any) => void;\nexport type subscriptionLogsToBeFn = (marbles: string | string[]) => void;\n\nexport class TestScheduler extends VirtualTimeScheduler {\n private hotObservables: HotObservable<any>[] = [];\n private coldObservables: ColdObservable<any>[] = [];\n private flushTests: FlushableTest[] = [];\n\n constructor(public assertDeepEqual: (actual: any, expected: any) => boolean | void) {\n super(VirtualAction, defaultMaxFrame);\n }\n\n createTime(marbles: string): number {\n const indexOf: number = marbles.indexOf('|');\n if (indexOf === -1) {\n throw new Error('marble diagram for time should have a completion marker \"|\"');\n }\n return indexOf * TestScheduler.frameTimeFactor;\n }\n\n createColdObservable<T>(marbles: string, values?: any, error?: any): ColdObservable<T> {\n if (marbles.indexOf('^') !== -1) {\n throw new Error('cold observable cannot have subscription offset \"^\"');\n }\n if (marbles.indexOf('!') !== -1) {\n throw new Error('cold observable cannot have unsubscription marker \"!\"');\n }\n const messages = TestScheduler.parseMarbles(marbles, values, error);\n const cold = new ColdObservable<T>(messages, this);\n this.coldObservables.push(cold);\n return cold;\n }\n\n createHotObservable<T>(marbles: string, values?: any, error?: any): HotObservable<T> {\n if (marbles.indexOf('!') !== -1) {\n throw new Error('hot observable cannot have unsubscription marker \"!\"');\n }\n const messages = TestScheduler.parseMarbles(marbles, values, error);\n const subject = new HotObservable<T>(messages, this);\n this.hotObservables.push(subject);\n return subject;\n }\n\n private materializeInnerObservable(observable: Observable<any>,\n outerFrame: number): TestMessage[] {\n const messages: TestMessage[] = [];\n observable.subscribe((value) => {\n messages.push({ frame: this.frame - outerFrame, notification: Notification.createNext(value) });\n }, (err) => {\n messages.push({ frame: this.frame - outerFrame, notification: Notification.createError(err) });\n }, () => {\n messages.push({ frame: this.frame - outerFrame, notification: Notification.createComplete() });\n });\n return messages;\n }\n\n expectObservable(observable: Observable<any>,\n unsubscriptionMarbles: string = null): ({ toBe: observableToBeFn }) {\n const actual: TestMessage[] = [];\n const flushTest: FlushableTest = { actual, ready: false };\n const unsubscriptionFrame = TestScheduler\n .parseMarblesAsSubscriptions(unsubscriptionMarbles).unsubscribedFrame;\n let subscription: Subscription;\n\n this.schedule(() => {\n subscription = observable.subscribe(x => {\n let value = x;\n // Support Observable-of-Observables\n if (x instanceof Observable) {\n value = this.materializeInnerObservable(value, this.frame);\n }\n actual.push({ frame: this.frame, notification: Notification.createNext(value) });\n }, (err) => {\n actual.push({ frame: this.frame, notification: Notification.createError(err) });\n }, () => {\n actual.push({ frame: this.frame, notification: Notification.createComplete() });\n });\n }, 0);\n\n if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {\n this.schedule(() => subscription.unsubscribe(), unsubscriptionFrame);\n }\n\n this.flushTests.push(flushTest);\n\n return {\n toBe(marbles: string, values?: any, errorValue?: any) {\n flushTest.ready = true;\n flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true);\n }\n };\n }\n\n expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({ toBe: subscriptionLogsToBeFn }) {\n const flushTest: FlushableTest = { actual: actualSubscriptionLogs, ready: false };\n this.flushTests.push(flushTest);\n return {\n toBe(marbles: string | string[]) {\n const marblesArray: string[] = (typeof marbles === 'string') ? [marbles] : marbles;\n flushTest.ready = true;\n flushTest.expected = marblesArray.map(marbles =>\n TestScheduler.parseMarblesAsSubscriptions(marbles)\n );\n }\n };\n }\n\n flush() {\n const hotObservables = this.hotObservables;\n while (hotObservables.length > 0) {\n hotObservables.shift().setup();\n }\n\n super.flush();\n const readyFlushTests = this.flushTests.filter(test => test.ready);\n while (readyFlushTests.length > 0) {\n const test = readyFlushTests.shift();\n this.assertDeepEqual(test.actual, test.expected);\n }\n }\n\n static parseMarblesAsSubscriptions(marbles: string): SubscriptionLog {\n if (typeof marbles !== 'string') {\n return new SubscriptionLog(Number.POSITIVE_INFINITY);\n }\n const len = marbles.length;\n let groupStart = -1;\n let subscriptionFrame = Number.POSITIVE_INFINITY;\n let unsubscriptionFrame = Number.POSITIVE_INFINITY;\n\n for (let i = 0; i < len; i++) {\n const frame = i * this.frameTimeFactor;\n const c = marbles[i];\n switch (c) {\n case '-':\n case ' ':\n break;\n case '(':\n groupStart = frame;\n break;\n case ')':\n groupStart = -1;\n break;\n case '^':\n if (subscriptionFrame !== Number.POSITIVE_INFINITY) {\n throw new Error('found a second subscription point \\'^\\' in a ' +\n 'subscription marble diagram. There can only be one.');\n }\n subscriptionFrame = groupStart > -1 ? groupStart : frame;\n break;\n case '!':\n if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {\n throw new Error('found a second subscription point \\'^\\' in a ' +\n 'subscription marble diagram. There can only be one.');\n }\n unsubscriptionFrame = groupStart > -1 ? groupStart : frame;\n break;\n default:\n throw new Error('there can only be \\'^\\' and \\'!\\' markers in a ' +\n 'subscription marble diagram. Found instead \\'' + c + '\\'.');\n }\n }\n\n if (unsubscriptionFrame < 0) {\n return new SubscriptionLog(subscriptionFrame);\n } else {\n return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);\n }\n }\n\n static parseMarbles(marbles: string,\n values?: any,\n errorValue?: any,\n materializeInnerObservables: boolean = false): TestMessage[] {\n if (marbles.indexOf('!') !== -1) {\n throw new Error('conventional marble diagrams cannot have the ' +\n 'unsubscription marker \"!\"');\n }\n const len = marbles.length;\n const testMessages: TestMessage[] = [];\n const subIndex = marbles.indexOf('^');\n const frameOffset = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);\n const getValue = typeof values !== 'object' ?\n (x: any) => x :\n (x: any) => {\n // Support Observable-of-Observables\n if (materializeInnerObservables && values[x] instanceof ColdObservable) {\n return values[x].messages;\n }\n return values[x];\n };\n let groupStart = -1;\n\n for (let i = 0; i < len; i++) {\n const frame = i * this.frameTimeFactor + frameOffset;\n let notification: Notification<any>;\n const c = marbles[i];\n switch (c) {\n case '-':\n case ' ':\n break;\n case '(':\n groupStart = frame;\n break;\n case ')':\n groupStart = -1;\n break;\n case '|':\n notification = Notification.createComplete();\n break;\n case '^':\n break;\n case '#':\n notification = Notification.createError(errorValue || 'error');\n break;\n default:\n notification = Notification.createNext(getValue(c));\n break;\n }\n\n if (notification) {\n testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification });\n }\n }\n return testMessages;\n }\n}\n"]}