21
21
*/
22
22
describe ( 'FavoritesService' , function ( ) {
23
23
24
- var FavoritesService , TraktTVv2 , $httpBackend ;
24
+ var FavoritesService , TraktTVv2 , $httpBackend , $q , $rootScope , $scope ;
25
25
26
26
beforeEach ( module ( 'DuckieTV.providers.favorites' ) ) ;
27
27
beforeEach ( module ( 'DuckieTV.providers.trakttvv2' ) ) ;
@@ -40,8 +40,14 @@ describe('FavoritesService', function() {
40
40
FavoritesService = _FavoritesService_ ;
41
41
TraktTVv2 = _TraktTVv2_ ;
42
42
$httpBackend = _$httpBackend_ ;
43
+
44
+ } ) ) ;
45
+
46
+ afterEach ( inject ( function ( $rootScope ) {
47
+ $rootScope . $apply ( ) ;
43
48
} ) ) ;
44
49
50
+
45
51
describe ( 'It should be initialized' , function ( ) {
46
52
47
53
it ( 'should have a favorites property' , function ( ) {
@@ -52,103 +58,74 @@ describe('FavoritesService', function() {
52
58
FavoritesService . getSeries ( ) . then ( function ( result ) {
53
59
expect ( angular . isArray ( result ) ) . toBe ( true ) ;
54
60
} ) ;
55
-
56
61
} ) ;
57
62
58
63
} ) ;
59
64
60
65
describe ( "It should be able to add Doctor Who to the database" , function ( ) {
61
66
62
- it ( 'Should be able to add Doctor Who from a parsed search result' , function ( ) {
67
+ it ( 'Should be able to add Doctor Who from a parsed search result' , function ( done ) {
68
+ var serie = null ;
63
69
TraktTVv2 . serie ( 'doctor-who-2005' ) . then ( function ( searchResults ) {
64
- expect ( searchResults . title ) . toMatch ( 'Doctor Who' ) ;
65
70
return searchResults ;
66
- } ) . then ( FavoritesService . addFavorite ) . then ( function ( serie ) {
67
- expect (
68
- serie . id !== false &&
69
- serie . banner == '' &&
70
- serie . overview == '' &&
71
- serie . TVDB_ID == '' &&
72
- serie . networkid == '' &&
73
- serie . actors == '' &&
74
- serie . airs_dayofweek == '' &&
75
- serie . airs_time == '' &&
76
- serie . contentrating == '' &&
77
- serie . firstaired == '' &&
78
- serie . genre == '' &&
79
- serie . language == '' &&
80
- serie . network == '' &&
81
- serie . rating == '' &&
82
- serie . ratingcount == '' &&
83
- serie . runtime == '' &&
84
- serie . status == '' &&
85
- serie . fanart == '' &&
86
- serie . poster == '' &&
87
- serie . displaycalendar == 1 ) . toBe ( true ) ;
88
- /** merge this
89
- air_day: "Saturday"
90
- air_day_utc: "Saturday"
91
- air_time: "20:30"
92
- air_time_utc: "20:30"
93
- certification: "TV-PG"
94
- country: "gb"
95
- first_aired: 1111869000
96
- first_aired_iso: "2005-03-26T12:30:00-08:00"
97
- first_aired_utc: 1111869000
98
- genres: ["action", "adventure", "drama", "science fiction"]
99
- images: {,…}
100
- banner: "https://walter.trakt.us/images/shows/000/056/872/banners/original/eb6561d0ee.jpg?1420722414"
101
- fanart: "https://walter.trakt.us/images/shows/000/056/872/fanarts/original/f5b14363ae.jpg?1420722413"
102
- poster: "https://walter.trakt.us/images/shows/000/056/872/posters/original/8c421e339d.jpg?1420722412"
103
- imdb_id: "tt0436992"
104
- in_watchlist: false
105
- last_updated: 1421256819
106
- network: "BBC One"
107
- overview: "The Doctor is an alien Time Lord from the planet Gallifrey who travels through all of time and space in his TARDIS. His current travel companion is Clara Oswald, though he has a long list of friends and companions who have shared journeys with him. Instead of dying, the Doctor is able to “regenerate” into a new body, taking on a new personality with each regeneration. Twelve actors, plus John Hurt, have played The Doctor thus far."
108
- people: {actors: [{name: "Peter Capaldi", images: {,…}, character: "The Doctor"},…] }
109
- actors: [{name: "Peter Capaldi", images: {,…}, character: "The Doctor"},…]
110
- poster: "https://walter.trakt.us/images/shows/000/056/872/posters/original/8c421e339d.jpg?1420722412"
111
- rating: false
112
- rating_advanced: false
113
- ratings: {percentage: 91, votes: 10210, loved: 0, hated: 0}
114
- runtime: 50
115
- seasons: [{season: 9, episodes: [,…]}, {season: 8,…},…]
116
- stats: {watchers: 0, plays: 0, scrobbles: 0, scrobbles_unique: 0, checkins: 0, checkins_unique: 0,…}
117
- checkins: 0
118
- checkins_unique: 0
119
- collection: 0
120
- collection_unique: 0
121
- plays: 0
122
- scrobbles: 0
123
- scrobbles_unique: 0
124
- watchers: 0
125
- status: "returning series"
126
- title: "Doctor Who"
127
- top_episodes: null
128
- top_watchers: null
129
- tvdb_id: 78804
130
- tvrage_id: 3332
131
- url: "http://trakt.tv/shows/doctor-who-2005"
132
- year: 2005
133
- */
134
-
71
+ } ) . then ( function ( result ) {
72
+ return FavoritesService . addFavorite ( result ) ;
73
+ } ) . then ( function ( serie ) {
74
+ expect ( serie ) . toEqual ( true ) ;
75
+ done ( ) ;
135
76
} ) ;
136
77
137
78
$httpBackend . flush ( ) ;
79
+
80
+
138
81
} ) ;
139
82
140
- it ( 'should have added 10 seasons' , function ( ) {
141
- CRUD . Find ( Season , {
83
+ it ( 'Shoud have finished adding it' , function ( ) {
84
+ var serie = null ;
85
+ CRUD . FindOne ( 'Serie' , {
86
+ name : 'Doctor Who'
87
+ } ) . then ( function ( serie ) {
88
+
89
+ expect (
90
+ serie . overview == "The Doctor is an alien Time Lord from the planet Gallifrey who travels through all of time and space in his TARDIS. His current travel companion is Clara Oswald, though he has a long list of friends and companions who have shared journeys with him. Instead of dying, the Doctor is able to “regenerate” into a new body, taking on a new personality with each regeneration. Twelve actors, plus John Hurt, have played The Doctor thus far." &&
91
+ serie . runtime == 50 &&
92
+ serie . network == 'BBC One' &&
93
+ serie . status == 'Continuing' &&
94
+ serie . rating == 9.11989 &&
95
+ serie . language == 'gb' &&
96
+ serie . fanart == 'https://walter.trakt.us/images/shows/000/056/872/fanarts/original/f5b14363ae.jpg?1420722413' &&
97
+ serie . poster == 'https://walter.trakt.us/images/shows/000/056/872/posters/thumb/8c421e339d.jpg?1420722412' &&
98
+ serie . banner == 'https://walter.trakt.us/images/shows/000/056/872/banners/original/eb6561d0ee.jpg?1420722414' &&
99
+ serie . TVDB_ID == 78804 &&
100
+ serie . TVRage_ID == 3332 &&
101
+ serie . IMDB_ID == 'tt0436992' &&
102
+ serie . contentrating == 'TV-PG' &&
103
+ serie . name == 'Doctor Who' &&
104
+ /* serie.firstaired == NaN && */
105
+ serie . ratingcount == 10176 &&
106
+ serie . genre == 'action|adventure|drama|science-fiction' &&
107
+ serie . ID_Serie == 1
108
+ ) . toBe ( true ) ;
109
+ done ( ) ;
110
+ } ) ;
111
+
112
+ } ) ;
113
+
114
+ it ( "Should have added 10 seasons" , function ( done ) {
115
+
116
+ CRUD . FindOne ( 'Season' , {
142
117
Serie : {
143
- name : 'Doctor Who'
118
+ title : 'Doctor Who'
144
119
}
145
- } ) . then ( function ( seasons ) {
146
- expect ( seasons . length == 9 ) . toBe ( true ) ;
147
- return seasons ;
120
+ } ) . then ( function ( result ) {
121
+ expect ( result . length ) . toEqual ( 9 ) ;
122
+ done ( ) ;
148
123
} ) ;
149
124
125
+
150
126
} ) ;
151
127
128
+
152
129
it ( 'should have added xx episodes' , function ( ) {
153
130
expect ( false ) . toBe ( true ) ; // placeholder
154
131
} ) ;
0 commit comments