@@ -11,7 +11,7 @@ import { intervalProvider } from 'rxjs/internal/scheduler/intervalProvider';
1111declare const rxTestScheduler : TestScheduler ;
1212
1313/** @test {TestScheduler} */
14- describe ( 'TestScheduler' , ( ) => {
14+ describe . only ( 'TestScheduler' , ( ) => {
1515 it ( 'should exist' , ( ) => {
1616 expect ( TestScheduler ) . exist ;
1717 expect ( TestScheduler ) . to . be . a ( 'function' ) ;
@@ -25,76 +25,88 @@ describe('TestScheduler', () => {
2525 it ( 'should parse a marble string into a series of notifications and types' , ( ) => {
2626 const result = TestScheduler . parseMarbles ( '-------a---b---|' , { a : 'A' , b : 'B' } ) ;
2727 expect ( result ) . deep . equal ( [
28- { frame : 70 , notification : nextNotification ( 'A' ) } ,
29- { frame : 110 , notification : nextNotification ( 'B' ) } ,
30- { frame : 150 , notification : COMPLETE_NOTIFICATION }
28+ { frame : 70 , notification : nextNotification ( 'A' ) , subscribing : false } ,
29+ { frame : 110 , notification : nextNotification ( 'B' ) , subscribing : false } ,
30+ { frame : 150 , notification : COMPLETE_NOTIFICATION , subscribing : false }
3131 ] ) ;
3232 } ) ;
3333
3434 it ( 'should parse a marble string, allowing spaces too' , ( ) => {
3535 const result = TestScheduler . parseMarbles ( '--a--b--| ' , { a : 'A' , b : 'B' } ) ;
3636 expect ( result ) . deep . equal ( [
37- { frame : 20 , notification : nextNotification ( 'A' ) } ,
38- { frame : 50 , notification : nextNotification ( 'B' ) } ,
39- { frame : 80 , notification : COMPLETE_NOTIFICATION }
37+ { frame : 20 , notification : nextNotification ( 'A' ) , subscribing : false } ,
38+ { frame : 50 , notification : nextNotification ( 'B' ) , subscribing : false } ,
39+ { frame : 80 , notification : COMPLETE_NOTIFICATION , subscribing : false }
4040 ] ) ;
4141 } ) ;
4242
4343 it ( 'should parse a marble string with a subscription point' , ( ) => {
4444 const result = TestScheduler . parseMarbles ( '---^---a---b---|' , { a : 'A' , b : 'B' } ) ;
4545 expect ( result ) . deep . equal ( [
46- { frame : 40 , notification : nextNotification ( 'A' ) } ,
47- { frame : 80 , notification : nextNotification ( 'B' ) } ,
48- { frame : 120 , notification : COMPLETE_NOTIFICATION }
46+ { frame : 40 , notification : nextNotification ( 'A' ) , subscribing : false } ,
47+ { frame : 80 , notification : nextNotification ( 'B' ) , subscribing : false } ,
48+ { frame : 120 , notification : COMPLETE_NOTIFICATION , subscribing : false }
4949 ] ) ;
5050 } ) ;
5151
5252 it ( 'should parse a marble string with an error' , ( ) => {
5353 const result = TestScheduler . parseMarbles ( '-------a---b---#' , { a : 'A' , b : 'B' } , 'omg error!' ) ;
5454 expect ( result ) . deep . equal ( [
55- { frame : 70 , notification : nextNotification ( 'A' ) } ,
56- { frame : 110 , notification : nextNotification ( 'B' ) } ,
57- { frame : 150 , notification : errorNotification ( 'omg error!' ) }
55+ { frame : 70 , notification : nextNotification ( 'A' ) , subscribing : false } ,
56+ { frame : 110 , notification : nextNotification ( 'B' ) , subscribing : false } ,
57+ { frame : 150 , notification : errorNotification ( 'omg error!' ) , subscribing : false }
5858 ] ) ;
5959 } ) ;
6060
6161 it ( 'should default in the letter for the value if no value hash was passed' , ( ) => {
6262 const result = TestScheduler . parseMarbles ( '--a--b--c--' ) ;
6363 expect ( result ) . deep . equal ( [
64- { frame : 20 , notification : nextNotification ( 'a' ) } ,
65- { frame : 50 , notification : nextNotification ( 'b' ) } ,
66- { frame : 80 , notification : nextNotification ( 'c' ) } ,
64+ { frame : 20 , notification : nextNotification ( 'a' ) , subscribing : false } ,
65+ { frame : 50 , notification : nextNotification ( 'b' ) , subscribing : false } ,
66+ { frame : 80 , notification : nextNotification ( 'c' ) , subscribing : false } ,
6767 ] ) ;
6868 } ) ;
6969
7070 it ( 'should handle grouped values' , ( ) => {
7171 const result = TestScheduler . parseMarbles ( '---(abc)---' ) ;
7272 expect ( result ) . deep . equal ( [
73- { frame : 30 , notification : nextNotification ( 'a' ) } ,
74- { frame : 30 , notification : nextNotification ( 'b' ) } ,
75- { frame : 30 , notification : nextNotification ( 'c' ) }
73+ { frame : 30 , notification : nextNotification ( 'a' ) , subscribing : false } ,
74+ { frame : 30 , notification : nextNotification ( 'b' ) , subscribing : false } ,
75+ { frame : 30 , notification : nextNotification ( 'c' ) , subscribing : false }
7676 ] ) ;
7777 } ) ;
7878
7979 it ( 'should ignore whitespace when runMode=true' , ( ) => {
8080 const runMode = true ;
8181 const result = TestScheduler . parseMarbles ( ' -a - b - c | ' , { a : 'A' , b : 'B' , c : 'C' } , undefined , undefined , runMode ) ;
8282 expect ( result ) . deep . equal ( [
83- { frame : 10 , notification : nextNotification ( 'A' ) } ,
84- { frame : 30 , notification : nextNotification ( 'B' ) } ,
85- { frame : 50 , notification : nextNotification ( 'C' ) } ,
86- { frame : 60 , notification : COMPLETE_NOTIFICATION }
83+ { frame : 10 , notification : nextNotification ( 'A' ) , subscribing : false } ,
84+ { frame : 30 , notification : nextNotification ( 'B' ) , subscribing : false } ,
85+ { frame : 50 , notification : nextNotification ( 'C' ) , subscribing : false } ,
86+ { frame : 60 , notification : COMPLETE_NOTIFICATION , subscribing : false }
8787 ] ) ;
8888 } ) ;
8989
90- it ( 'should suppport time progression syntax when runMode=true' , ( ) => {
90+ it ( 'should support time progression syntax when runMode=true' , ( ) => {
9191 const runMode = true ;
9292 const result = TestScheduler . parseMarbles ( '10.2ms a 1.2s b 1m c|' , { a : 'A' , b : 'B' , c : 'C' } , undefined , undefined , runMode ) ;
9393 expect ( result ) . deep . equal ( [
94- { frame : 10.2 , notification : nextNotification ( 'A' ) } ,
95- { frame : 10.2 + 10 + ( 1.2 * 1000 ) , notification : nextNotification ( 'B' ) } ,
96- { frame : 10.2 + 10 + ( 1.2 * 1000 ) + 10 + ( 1000 * 60 ) , notification : nextNotification ( 'C' ) } ,
97- { frame : 10.2 + 10 + ( 1.2 * 1000 ) + 10 + ( 1000 * 60 ) + 10 , notification : COMPLETE_NOTIFICATION }
94+ { frame : 10.2 , notification : nextNotification ( 'A' ) , subscribing : false } ,
95+ { frame : 10.2 + 10 + ( 1.2 * 1000 ) , notification : nextNotification ( 'B' ) , subscribing : false } ,
96+ { frame : 10.2 + 10 + ( 1.2 * 1000 ) + 10 + ( 1000 * 60 ) , notification : nextNotification ( 'C' ) , subscribing : false } ,
97+ { frame : 10.2 + 10 + ( 1.2 * 1000 ) + 10 + ( 1000 * 60 ) + 10 , notification : COMPLETE_NOTIFICATION , subscribing : false }
98+ ] ) ;
99+ } ) ;
100+
101+ it ( 'should support a synchronous-within-subscribe marker' , ( ) => {
102+ const runMode = true ;
103+ const result = TestScheduler . parseMarbles ( '--(^abc)--(d|)' , undefined , undefined , undefined , runMode ) ;
104+ expect ( result ) . deep . equal ( [
105+ { frame : 20 , notification : nextNotification ( 'a' ) , subscribing : true } ,
106+ { frame : 20 , notification : nextNotification ( 'b' ) , subscribing : true } ,
107+ { frame : 20 , notification : nextNotification ( 'c' ) , subscribing : true } ,
108+ { frame : 100 , notification : nextNotification ( 'd' ) , subscribing : false } ,
109+ { frame : 100 , notification : COMPLETE_NOTIFICATION , subscribing : false }
98110 ] ) ;
99111 } ) ;
100112 } ) ;
@@ -161,10 +173,10 @@ describe('TestScheduler', () => {
161173 expect ( expected . length ) . to . equal ( 0 ) ;
162174 } ) ;
163175
164- it ( 'should emit notifications at frame zero synchronously upon subscription' , ( ) => {
176+ it ( 'should emit notifications marked with "^" synchronously upon subscription' , ( ) => {
165177 const result : string [ ] = [ ] ;
166178 const scheduler = new TestScheduler ( null ! ) ;
167- const source = scheduler . createColdObservable ( '(ab|)' ) ;
179+ const source = scheduler . createColdObservable ( '(^ ab|)' ) ;
168180 source . subscribe ( {
169181 next : ( value ) => result . push ( value ) ,
170182 complete : ( ) => result . push ( 'complete' ) ,
@@ -252,7 +264,7 @@ describe('TestScheduler', () => {
252264 } ) ;
253265
254266 it ( 'should handle empty' , ( ) => {
255- expectObservable ( EMPTY ) . toBe ( '| ' , { } ) ;
267+ expectObservable ( EMPTY ) . toBe ( '(^|) ' , { } ) ;
256268 } ) ;
257269
258270 it ( 'should handle never' , ( ) => {
0 commit comments