@@ -11,7 +11,7 @@ describe('ScalarObservable', function () {
1111 expect ( s . value ) . toBe ( 1 ) ;
1212 } ) ;
1313
14- it ( 'should create ScalarObservable via staic create function' , function ( ) {
14+ it ( 'should create ScalarObservable via static create function' , function ( ) {
1515 var s = new ScalarObservable ( 1 ) ;
1616 var r = ScalarObservable . create ( 1 ) ;
1717
@@ -25,179 +25,4 @@ describe('ScalarObservable', function () {
2525 subscriber . isUnsubscribed = true ;
2626 rxTestScheduler . flush ( ) ;
2727 } ) ;
28-
29- describe ( 'prototype.map()' , function ( ) {
30- it ( 'should map to a new ScalarObservable' , function ( ) {
31- var s = new ScalarObservable ( 1 ) ;
32- var r = s . map ( function ( x ) { return x + '!!!' ; } ) ;
33- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
34- expect ( r . value ) . toBe ( '1!!!' ) ;
35- } ) ;
36-
37- it ( 'should map using a custom thisArg' , function ( ) {
38- var s = new ScalarObservable ( 1 ) ;
39- var foo = 42 ;
40- var selector = function ( x ) {
41- expect ( this ) . toEqual ( foo ) ;
42- return x + '!!!' ;
43- } ;
44- var r = s . map ( selector , 42 ) ;
45-
46- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
47- expect ( r . value ) . toBe ( '1!!!' ) ;
48- } ) ;
49-
50- it ( 'should return an ErrorObservable if map errors' , function ( ) {
51- var s = new ScalarObservable ( 1 ) ;
52- var r = s . map ( function ( x ) { throw 'bad!' ; } ) ;
53- expect ( r instanceof ErrorObservable ) . toBe ( true ) ;
54- expect ( r . error ) . toBe ( 'bad!' ) ;
55- } ) ;
56- } ) ;
57-
58- describe ( 'prototype.count()' , function ( ) {
59- it ( 'should map to a new ScalarObservable of 1' , function ( ) {
60- var s = new ScalarObservable ( 1 ) ;
61- var r = s . count ( ) ;
62- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
63- expect ( r . value ) . toBe ( 1 ) ;
64- } ) ;
65-
66- it ( 'should map to a new ScalarObservable of 1 if predicate matches' , function ( ) {
67- var s = new ScalarObservable ( 1 ) ;
68- var r = s . count ( function ( x ) { return x === 1 ; } ) ;
69- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
70- expect ( r . value ) . toBe ( 1 ) ;
71- } ) ;
72-
73- it ( 'should map to a new ScalarObservable of 0 if predicate does not match' , function ( ) {
74- var s = new ScalarObservable ( 1 ) ;
75- var r = s . count ( function ( x ) { return x === 0 ; } ) ;
76- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
77- expect ( r . value ) . toBe ( 0 ) ;
78- } ) ;
79-
80- it ( 'should map to a new ErrorObservable if predicate errors' , function ( ) {
81- var s = new ScalarObservable ( 1 ) ;
82- var r = s . count ( function ( ) { throw 'bad!' ; } ) ;
83- expect ( r instanceof ErrorObservable ) . toBe ( true ) ;
84- expect ( r . error ) . toBe ( 'bad!' ) ;
85- } ) ;
86- } ) ;
87-
88- describe ( 'prototype.filter()' , function ( ) {
89- it ( 'should return itself if the filter matches its value' , function ( ) {
90- var s = new ScalarObservable ( 1 ) ;
91- var r = s . filter ( function ( x ) { return x === 1 ; } ) ;
92- expect ( s ) . toBe ( r ) ;
93- } ) ;
94-
95- it ( 'should filter using a custom thisArg' , function ( ) {
96- var s = new ScalarObservable ( 1 ) ;
97- var filterer = {
98- filter1 : function ( x ) { return x > 0 ; } ,
99- filter2 : function ( x ) { return x === 1 ; }
100- } ;
101-
102- var r = s
103- . filter ( function ( x ) { return this . filter1 ( x ) ; } , filterer )
104- . filter ( function ( x ) { return this . filter2 ( x ) ; } , filterer ) ;
105-
106- expect ( s ) . toBe ( r ) ;
107- } ) ;
108-
109- it ( 'should return EmptyObservable if filter does not match' , function ( ) {
110- var s = new ScalarObservable ( 1 ) ;
111- var r = s . filter ( function ( x ) { return x === 0 ; } ) ;
112- expect ( r instanceof EmptyObservable ) . toBe ( true ) ;
113- } ) ;
114-
115- it ( 'should map to a new ErrorObservable if predicate errors' , function ( ) {
116- var s = new ScalarObservable ( 1 ) ;
117- var r = s . filter ( function ( ) { throw 'bad!' ; } ) ;
118- expect ( r instanceof ErrorObservable ) . toBe ( true ) ;
119- expect ( r . error ) . toBe ( 'bad!' ) ;
120- } ) ;
121- } ) ;
122-
123- describe ( 'prototype.take()' , function ( ) {
124- it ( 'should return itself if count > 0' , function ( ) {
125- var s = new ScalarObservable ( 1 ) ;
126- var r = s . take ( 1 ) ;
127- expect ( s ) . toBe ( r ) ;
128- } ) ;
129-
130- it ( 'should return EmptyObservable if count === 0' , function ( ) {
131- var s = new ScalarObservable ( 1 ) ;
132- var r = s . take ( 0 ) ;
133- expect ( r instanceof EmptyObservable ) . toBe ( true ) ;
134- } ) ;
135- } ) ;
136-
137- describe ( 'prototype.skip()' , function ( ) {
138- it ( 'should return itself if count === 0' , function ( ) {
139- var s = new ScalarObservable ( 1 ) ;
140- var r = s . skip ( 0 ) ;
141- expect ( s ) . toBe ( r ) ;
142- } ) ;
143-
144- it ( 'should return EmptyObservable if count > 0' , function ( ) {
145- var s = new ScalarObservable ( 1 ) ;
146- var r = s . skip ( 1 ) ;
147- expect ( r instanceof EmptyObservable ) . toBe ( true ) ;
148- } ) ;
149- } ) ;
150-
151- describe ( 'prototype.reduce()' , function ( ) {
152- it ( 'should return a ScalarObservable of the result if there is a seed' , function ( ) {
153- var s = new ScalarObservable ( 1 ) ;
154- var r = s . reduce ( function ( a , x ) { return a + x ; } , 1 ) ;
155- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
156- expect ( r . value ) . toBe ( 2 ) ;
157- } ) ;
158-
159- it ( 'should return itself if there is no seed' , function ( ) {
160- var s = new ScalarObservable ( 1 ) ;
161- var r = s . reduce ( function ( a , x ) { return a + x ; } ) ;
162- expect ( r ) . toBe ( s ) ;
163- } ) ;
164-
165- it ( 'should return ErrorObservable if projection throws' , function ( ) {
166- var s = new ScalarObservable ( 1 ) ;
167- var r = s . reduce ( function ( a , x ) { throw 'error' ; } , 1 ) ;
168- var expected = new ErrorObservable ( 'error' ) ;
169-
170- expect ( r ) . toEqual ( expected ) ;
171- } ) ;
172- } ) ;
173-
174- describe ( 'prototype.scan()' , function ( ) {
175- it ( 'should return a ScalarObservable of the result if there is a seed' , function ( ) {
176- var s = new ScalarObservable ( 1 ) ;
177- var r = s . scan ( function ( a , x ) { return a + x ; } , 1 ) ;
178- expect ( r instanceof ScalarObservable ) . toBe ( true ) ;
179- expect ( r . value ) . toBe ( 2 ) ;
180- } ) ;
181-
182- it ( 'should return itself if there is no seed' , function ( ) {
183- var s = new ScalarObservable ( 1 ) ;
184- var r = s . scan ( function ( a , x ) { return a + x ; } ) ;
185- expect ( r ) . toBe ( s ) ;
186- } ) ;
187-
188- it ( 'should return ErrorObservable if projection throws' , function ( ) {
189- var s = new ScalarObservable ( 1 ) ;
190- var r = s . scan ( function ( a , x ) { throw 'error' ; } , 1 ) ;
191- var expected = new ErrorObservable ( 'error' ) ;
192-
193- expect ( r ) . toEqual ( expected ) ;
194- } ) ;
195- } ) ;
196- } ) ;
197-
198- // If you uncomment this, jasmine breaks? WEIRD
199- // describe('reality', function () {
200- // it('should exist in this universe', function () {
201- // expect(true).toBe(true);
202- // });
203- // });
28+ } ) ;
0 commit comments