1+ describe ( 'gmDirections' , function ( ) {
2+
3+ var $compile , $rootScope , $scope , $timeout ,
4+ element , scope , googleMaps ;
5+
6+
7+ //---------------------------------------------------------------------------
8+ // Load Library
9+ //---------------------------------------------------------------------------
10+
11+ testTools . mokeGMLibrary ( ) ;
12+
13+
14+ //---------------------------------------------------------------------------
15+ // Inject required
16+ //---------------------------------------------------------------------------
17+ beforeEach ( inject ( function ( _$rootScope_ , _$timeout_ , _$compile_ ) {
18+ $rootScope = _$rootScope_ ;
19+ $timeout = _$timeout_ ;
20+ $compile = _$compile_ ;
21+ $scope = $rootScope . $new ( ) ;
22+ googleMaps = $rootScope . google . maps ;
23+ } ) ) ;
24+
25+
26+ //---------------------------------------------------------------------------
27+ // TESTS
28+ //---------------------------------------------------------------------------
29+
30+
31+ function compile ( template ) {
32+ element = $compile ( '<gm-map options="{center: [37, -122], zoom: 8}">' + template + '</gm-map>' ) ( $scope ) ;
33+ $scope . $digest ( ) ;
34+ $timeout . flush ( ) ;
35+ element = element . find ( 'gm-directions' ) ;
36+ scope = element . scope ( ) ;
37+ }
38+
39+ it ( 'test simple case' , function ( done ) {
40+ compile ( '<gm-directions destination="destination" options="{origin: \'from\', destination: \'to\', travelMode: \'mode\'}"></gm-directions>' ) ;
41+
42+ setTimeout ( function ( ) {
43+ expect ( scope . directions ) . not . to . be . an ( 'undefined' ) ;
44+ expect ( scope . directions . result . options . origin ) . to . be . equal ( 'from' ) ;
45+ expect ( scope . directions . result . options . destination ) . to . be . equal ( 'to' ) ;
46+ expect ( scope . directions . result . options . travelMode ) . to . be . equal ( 'mode' ) ;
47+
48+ done ( ) ;
49+ } , 10 ) ;
50+ } ) ;
51+
52+ it ( 'test mandatory properties' , function ( done ) {
53+ compile ( '<gm-directions origin="o" destination="d" travelMode="t"></gm-directions>' ) ;
54+
55+ setTimeout ( function ( ) {
56+ expect ( scope . directions ) . to . be . an ( 'undefined' ) ;
57+ $scope . o = 'from' ;
58+ $scope . $digest ( ) ;
59+ setTimeout ( function ( ) {
60+ expect ( scope . directions ) . to . be . an ( 'undefined' ) ;
61+ $scope . d = 'to' ;
62+ $scope . $digest ( ) ;
63+ setTimeout ( function ( ) {
64+ expect ( scope . directions ) . to . be . an ( 'undefined' ) ;
65+ $scope . t = 'mode' ;
66+ $scope . $digest ( ) ;
67+ setTimeout ( function ( ) {
68+ expect ( scope . directions ) . not . to . be . an ( 'undefined' ) ;
69+ expect ( scope . directions . result . options . origin ) . to . be . equal ( 'from' ) ;
70+ expect ( scope . directions . result . options . destination ) . to . be . equal ( 'to' ) ;
71+ expect ( scope . directions . result . options . travelMode ) . to . be . equal ( 'mode' ) ;
72+ done ( ) ;
73+ } , 10 ) ;
74+ } , 10 ) ;
75+ } , 10 ) ;
76+ } , 10 ) ;
77+ } ) ;
78+
79+ } ) ;
0 commit comments