@@ -87,13 +87,72 @@ describe '.matchers', ->
87
87
Then -> @ matches (td .matchers .contains (true , 5 , null , undefined ), [true , 5 , undefined , null ]) == true
88
88
Then -> @ matches (td .matchers .contains (true , 5 , null , undefined ), [true , 5 , null ]) == false
89
89
90
+ describe ' elements containing matchers' , ->
91
+ Then -> @ matches (td .matchers .contains (' b' , td .matchers .isA (Number )), [' a' , 3 , ' b' ]) == true
92
+
90
93
context ' objects' , ->
91
94
Then -> @ matches (td .matchers .contains (foo : ' bar' , baz : 42 ), foo : ' bar' , baz : 42 , stuff : this ) == true
92
95
Then -> @ matches (td .matchers .contains (foo : ' bar' , lol : 42 ), foo : ' bar' , baz : 42 ) == false
93
96
Then -> @ matches (td .matchers .contains (lol : {deep : [4 ,2 ]}), lol : {deep : [4 ,2 ], other : " stuff" }) == true
94
97
Then -> @ matches (td .matchers .contains (deep : {thing : ' stuff' }), {}) == false
95
- Then -> @ matches (td .matchers .contains (deep : {thing : ' stuff' }), deep : {thing : ' stuff' , shallow : 5 }) == true
96
- Then -> @ matches (td .matchers .contains ({container : {size : ' S' }}), {ingredient : ' beans' , container : { type : ' cup' , size : ' S' }}) == true
98
+ Then -> @ matches (td .matchers .contains (deep : {thing : ' stuff' }),
99
+ deep : {thing : ' stuff' , shallow : 5 }
100
+ ) == true
101
+ Then -> @ matches (td .matchers .contains ({container : {size : ' S' }}),
102
+ {ingredient : ' beans' , container : { type : ' cup' , size : ' S' }}
103
+ ) == true
104
+
105
+ describe ' objects containing matchers' , ->
106
+ Then -> @ matches (td .matchers .contains (td .matchers .isA (Number )),
107
+ {a : ' foo' , b : 32 }
108
+ ) == true
109
+ Then -> @ matches (td .matchers .contains (td .matchers .isA (Function )),
110
+ {a : ' foo' , b : 32 }
111
+ ) == false
112
+ Then -> @ matches (td .matchers .contains ({a : td .matchers .contains (1 ,2 )}),
113
+ {a : [4 ,1 ,2 ,3 ]}
114
+ ) == true
115
+ Then -> @ matches (td .matchers .contains ({a : td .matchers .contains (1 ,5 )}),
116
+ {a : [4 ,1 ,2 ,3 ]}
117
+ ) == false
118
+ Then -> @ matches (
119
+ td .matchers .contains ({someString : td .matchers .isA (String )}),
120
+ {someString : " beautifulString" }
121
+ ) == true
122
+ Then -> @ matches (
123
+ td .matchers .contains ({someString : td .matchers .isA (String )}),
124
+ {someString : " beautifulString" , irrelevant : true }
125
+ ) == true
126
+ Then -> @ matches (
127
+ td .matchers .contains (
128
+ {nested : {someString : td .matchers .isA (String )}, relevant : true }
129
+ ),
130
+ {nested : {someString : " beautifulString" }, relevant : true }
131
+ ) == true
132
+ Then -> @ matches (
133
+ td .matchers .contains ({someString : td .matchers .isA (String )}),
134
+ {someString : 4 }
135
+ ) == false
136
+ Then -> @ matches (
137
+ td .matchers .contains ({
138
+ nested : td .matchers .contains ({
139
+ nestedString : td .matchers .isA (String )
140
+ })
141
+ }),
142
+ {nested : {nestedString : " abc" , irrelevant : true }, irrelevantHere : " alsoTrue" }
143
+ ) == true
144
+ Then -> @ matches (
145
+ td .matchers .contains ({
146
+ nested : td .matchers .contains ({
147
+ nestedString : td .matchers .isA (Number )
148
+ })
149
+ }),
150
+ {nested : {nestedString : " abc" , irrelevant : true }, irrelevantHere : " not a number!" }
151
+ ) == false
152
+ Then -> @ matches (td .matchers .contains ({a : [td .matchers .isA (Number )]}),
153
+ {a : [5 ]}
154
+ ) == true
155
+
97
156
98
157
context ' regexp' , ->
99
158
Then -> @ matches (td .matchers .contains (/ abc/ ), ' abc' ) == true
0 commit comments