3
3
/* jasmine specs for controllers go here */
4
4
describe ( 'PhoneCat controllers' , function ( ) {
5
5
6
+ beforeEach ( function ( ) {
7
+ this . addMatchers ( {
8
+ toEqualData : function ( expected ) {
9
+ return angular . equals ( this . actual , expected ) ;
10
+ }
11
+ } ) ;
12
+ } ) ;
13
+
6
14
beforeEach ( module ( 'phonecatApp' ) ) ;
15
+ beforeEach ( module ( 'phonecatServices' ) ) ;
7
16
8
17
describe ( 'PhoneListCtrl' , function ( ) {
9
18
var scope , ctrl , $httpBackend ;
@@ -19,11 +28,11 @@ describe('PhoneCat controllers', function() {
19
28
20
29
21
30
it ( 'should create "phones" model with 2 phones fetched from xhr' , function ( ) {
22
- expect ( scope . phones ) . toBeUndefined ( ) ;
31
+ expect ( scope . phones ) . toEqualData ( [ ] ) ;
23
32
$httpBackend . flush ( ) ;
24
33
25
- expect ( scope . phones ) . toEqual ( [ { name : 'Nexus S' } ,
26
- { name : 'Motorola DROID' } ] ) ;
34
+ expect ( scope . phones ) . toEqualData (
35
+ [ { name : 'Nexus S' } , { name : 'Motorola DROID' } ] ) ;
27
36
} ) ;
28
37
29
38
@@ -54,10 +63,10 @@ describe('PhoneCat controllers', function() {
54
63
55
64
56
65
it ( 'should fetch phone detail' , function ( ) {
57
- expect ( scope . phone ) . toBeUndefined ( ) ;
66
+ expect ( scope . phone ) . toEqualData ( { } ) ;
58
67
$httpBackend . flush ( ) ;
59
68
60
- expect ( scope . phone ) . toEqual ( xyzPhoneData ( ) ) ;
69
+ expect ( scope . phone ) . toEqualData ( xyzPhoneData ( ) ) ;
61
70
} ) ;
62
71
} ) ;
63
72
} ) ;
0 commit comments