@@ -24,6 +24,53 @@ describe('using the connectFilter(...) mixin',function(){
24
24
} ) ;
25
25
} ) ;
26
26
27
+ describe ( "when filter func returns" , function ( ) {
28
+ var listenable , context , expectedResult ;
29
+ function withFilterReturning ( val ) {
30
+ var key = "KEY" ;
31
+ listenable = {
32
+ listen : sinon . spy ( ) ,
33
+ getInitialState : sinon . stub ( ) . returns ( "DOES NOT MATTER" )
34
+ } ;
35
+ context = { setState : sinon . spy ( ) } ;
36
+ expectedResult = { } ;
37
+ expectedResult [ key ] = val ;
38
+ _ . extend ( context , connectFilter ( listenable , key , function ( ) { return val ; } ) ) ;
39
+ }
40
+ describe ( "0" , function ( ) {
41
+ beforeEach ( function ( ) {
42
+ withFilterReturning ( 0 ) ;
43
+ } ) ;
44
+ it ( "should return that value" , function ( ) {
45
+ assert . deepEqual ( expectedResult , context . getInitialState ( ) ) ;
46
+ } ) ;
47
+ } ) ;
48
+ describe ( "empty string" , function ( ) {
49
+ beforeEach ( function ( ) {
50
+ withFilterReturning ( "" ) ;
51
+ } ) ;
52
+ it ( "should return that value" , function ( ) {
53
+ assert . deepEqual ( expectedResult , context . getInitialState ( ) ) ;
54
+ } ) ;
55
+ } ) ;
56
+ describe ( "false" , function ( ) {
57
+ beforeEach ( function ( ) {
58
+ withFilterReturning ( false ) ;
59
+ } ) ;
60
+ it ( "should return that value" , function ( ) {
61
+ assert . deepEqual ( expectedResult , context . getInitialState ( ) ) ;
62
+ } ) ;
63
+ } ) ;
64
+ describe ( "undefined" , function ( ) {
65
+ beforeEach ( function ( ) {
66
+ withFilterReturning ( ) ;
67
+ } ) ;
68
+ it ( "should return empty object" , function ( ) {
69
+ assert . deepEqual ( { } , context . getInitialState ( ) ) ;
70
+ } ) ;
71
+ } ) ;
72
+ } ) ;
73
+
27
74
describe ( "when calling without key" , function ( ) {
28
75
var initialstate = "DEFAULTDATA" ,
29
76
listenable = {
0 commit comments