33/* jasmine specs for controllers go here */
44describe ( 'PhoneCat controllers' , function ( ) {
55
6+ beforeEach ( function ( ) {
7+ this . addMatchers ( {
8+ toEqualData : function ( expected ) {
9+ return angular . equals ( this . actual , expected ) ;
10+ }
11+ } ) ;
12+ } ) ;
13+
614 beforeEach ( module ( 'phonecatApp' ) ) ;
15+ beforeEach ( module ( 'phonecatServices' ) ) ;
716
817 describe ( 'PhoneListCtrl' , function ( ) {
918 var scope , ctrl , $httpBackend ;
@@ -19,11 +28,11 @@ describe('PhoneCat controllers', function() {
1928
2029
2130 it ( 'should create "phones" model with 2 phones fetched from xhr' , function ( ) {
22- expect ( scope . phones ) . toBeUndefined ( ) ;
31+ expect ( scope . phones ) . toEqualData ( [ ] ) ;
2332 $httpBackend . flush ( ) ;
2433
25- expect ( scope . phones ) . toEqual ( [ { name : 'Nexus S' } ,
26- { name : 'Motorola DROID' } ] ) ;
34+ expect ( scope . phones ) . toEqualData (
35+ [ { name : 'Nexus S' } , { name : 'Motorola DROID' } ] ) ;
2736 } ) ;
2837
2938
@@ -54,10 +63,10 @@ describe('PhoneCat controllers', function() {
5463
5564
5665 it ( 'should fetch phone detail' , function ( ) {
57- expect ( scope . phone ) . toBeUndefined ( ) ;
66+ expect ( scope . phone ) . toEqualData ( { } ) ;
5867 $httpBackend . flush ( ) ;
5968
60- expect ( scope . phone ) . toEqual ( xyzPhoneData ( ) ) ;
69+ expect ( scope . phone ) . toEqualData ( xyzPhoneData ( ) ) ;
6170 } ) ;
6271 } ) ;
6372} ) ;
0 commit comments