@@ -13,7 +13,8 @@ describe('Hypermedia API', function() {
1313 it ( 'should load root resource' , function ( done ) {
1414 var ripple = hypermedia ( data ( core ( ) ) )
1515 ripple ( 'github' , 'https://api.github.com' , { http : http } )
16- ripple ( 'github' ) . once ( 'change' , function ( github ) {
16+ ripple ( 'github' ) . once ( 'change' , function ( change ) {
17+ var github = change . value
1718 expect ( keys ( github ) . length ) . to . be . gt ( 10 )
1819 done ( )
1920 } )
@@ -22,7 +23,8 @@ describe('Hypermedia API', function() {
2223 it ( 'should follow links' , function ( done ) {
2324 var ripple = hypermedia ( data ( core ( ) ) )
2425 ripple ( 'github' , 'https://api.github.com' , { http : http } )
25- ripple ( 'github.current_user_url' ) . on ( 'change' , function ( user ) {
26+ ripple ( 'github.current_user_url' ) . on ( 'change' , function ( change ) {
27+ var user = change . value
2628 if ( ! user . login ) return
2729 expect ( 'github' in ripple . resources ) . to . be . ok
2830 expect ( 'github.current_user_url' in ripple . resources ) . to . be . ok
@@ -35,7 +37,8 @@ describe('Hypermedia API', function() {
3537 it ( 'should load and cache intermediate links' , function ( done ) {
3638 var ripple = hypermedia ( data ( core ( ) ) )
3739 ripple ( 'github' , 'https://api.github.com' , { http : http } )
38- ripple ( 'github.current_user_url.id' ) . on ( 'change' , function ( user ) {
40+ ripple ( 'github.current_user_url.id' ) . on ( 'change' , function ( change ) {
41+ var user = change . value
3942 if ( ! user . value ) return
4043 expect ( 'github' in ripple . resources ) . to . be . ok
4144 expect ( 'github.current_user_url' in ripple . resources ) . to . be . ok
@@ -48,7 +51,8 @@ describe('Hypermedia API', function() {
4851 it ( 'should work with arrays' , function ( done ) {
4952 var ripple = hypermedia ( data ( core ( ) ) )
5053 ripple ( 'github' , 'https://api.github.com' , { http : http } )
51- ripple ( 'github.current_user_url.repos_url.0' ) . on ( 'change' , function ( repo ) {
54+ ripple ( 'github.current_user_url.repos_url.0' ) . on ( 'change' , function ( change ) {
55+ var repo = change . value
5256 if ( ! repo . name ) return
5357 expect ( repo . name ) . to . eql ( 'builder' )
5458 done ( )
@@ -58,7 +62,8 @@ describe('Hypermedia API', function() {
5862 it ( 'should traverse deep simple keys too' , function ( done ) {
5963 var ripple = hypermedia ( data ( core ( ) ) )
6064 ripple ( 'github' , 'https://api.github.com' , { http : http } )
61- ripple ( 'github.current_user_url.repos_url.0.owner.login' ) . on ( 'change' , function ( login ) {
65+ ripple ( 'github.current_user_url.repos_url.0.owner.login' ) . on ( 'change' , function ( change ) {
66+ var login = change . value
6267 if ( ! login . value ) return
6368 expect ( login . value ) . to . eql ( 'OGLES' )
6469 done ( )
@@ -71,7 +76,8 @@ describe('Hypermedia API', function() {
7176
7277 ripple ( 'github' , 'https://api.github.com' , { http : http } )
7378
74- ripple ( 'github.current_user_url' ) . on ( 'change.first' , function ( user ) {
79+ ripple ( 'github.current_user_url' ) . on ( 'change.first' , function ( change ) {
80+ var user = change . value
7581 if ( ! user . login ) return
7682 ripple ( 'github.current_user_url' ) . on ( 'change.second' , Function ( 'throw Error' ) )
7783 time ( 1000 , done )
@@ -81,7 +87,8 @@ describe('Hypermedia API', function() {
8187 it ( 'should fail if cannot fetch resource - general' , function ( done ) {
8288 var ripple = hypermedia ( data ( core ( ) ) )
8389 ripple ( 'github' , 'https://api.github.com' )
84- ripple ( 'github.current_user_url' ) . on ( 'change' , function ( body ) {
90+ ripple ( 'github.current_user_url' ) . on ( 'change' , function ( change ) {
91+ var body = change . value
8592 expect ( body ) . to . be . eql ( { } )
8693 } )
8794
@@ -108,11 +115,14 @@ describe('Hypermedia API', function() {
108115 var ripple = hypermedia ( data ( core ( ) ) )
109116 ripple ( 'github' , 'https://api.github.com' , { http : http } )
110117 ripple ( 'repo' , { owner : 'pemrouz' , repo : 'ripple' } , { link : 'github.repository_url' } )
111- . on ( 'change' , function ( repo ) {
118+ . on ( 'change' , function ( change ) {
119+ var repo = change . value
120+ if ( ! ripple ( 'repo' ) . value ) return
121+ if ( ! repo . id ) return
112122 expect ( 'repo' in ripple . resources ) . to . be . ok
113123 expect ( 'github' in ripple . resources ) . to . be . ok
114124 expect ( 'github.repository_url' in ripple . resources ) . to . be . ok
115- expect ( ripple ( 'repo' ) . id ) . to . be . equal ( 21631189 )
125+ expect ( ripple ( 'repo' ) . value . id ) . to . be . equal ( 21631189 )
116126 expect ( ripple . resources [ 'repo' ] . headers . timestamp ) . to . be . ok
117127 done ( )
118128 } )
@@ -122,7 +132,8 @@ describe('Hypermedia API', function() {
122132 var ripple = hypermedia ( data ( core ( ) ) )
123133 ripple ( 'github' , 'https://api.github.com' , { http : http } )
124134 ripple ( 'github.repository_url' , { owner : 'pemrouz' , repo : 'ripple' } )
125- . on ( 'change' , function ( repo ) {
135+ . on ( 'change' , function ( change ) {
136+ var repo = change . value
126137 if ( ! repo . id ) return
127138 expect ( 'github' in ripple . resources ) . to . be . ok
128139 expect ( 'github.repository_url' in ripple . resources ) . to . be . ok
@@ -139,8 +150,10 @@ describe('Hypermedia API', function() {
139150 var ripple = hypermedia ( data ( core ( ) ) )
140151 ripple ( 'repo' , 'https://api.github.com/repos/pemrouz/ripple' , { http : http } )
141152 ripple ( 'repo.issues_url' , { number : 1 } )
142- . on ( 'change' , function ( issue ) {
153+ . on ( 'change' , function ( change ) {
154+ var issue = change . value
143155 if ( ! issue . id ) return
156+ if ( ! ripple ( 'repo.issues_url' ) ) return
144157 expect ( 'repo' in ripple . resources ) . to . be . ok
145158 expect ( 'repo.issues_url' in ripple . resources ) . to . be . ok
146159 expect ( ripple ( 'repo.issues_url' ) . id ) . to . be . equal ( 39576741 )
@@ -153,12 +166,15 @@ describe('Hypermedia API', function() {
153166 var ripple = hypermedia ( data ( core ( ) ) )
154167 ripple ( 'github' , 'https://api.github.com' , { http : http } )
155168 ripple ( 'issue' , { owner : 'pemrouz' , repo : 'ripple' , number : 1 } , { link : 'github.repository_url.issues_url' } )
156- . on ( 'change' , function ( issue ) {
169+ . on ( 'change' , function ( change ) {
170+ var issue = change . value
171+ if ( ! ripple ( 'issue' ) . value ) return
172+ if ( ! issue . id ) return
157173 expect ( 'issue' in ripple . resources ) . to . be . ok
158174 expect ( 'github' in ripple . resources ) . to . be . ok
159175 expect ( 'github.repository_url' in ripple . resources ) . to . be . ok
160176 expect ( 'github.repository_url.issues_url' in ripple . resources ) . to . be . ok
161- expect ( ripple ( 'issue' ) . id ) . to . be . equal ( 39576741 )
177+ expect ( ripple ( 'issue' ) . value . id ) . to . be . equal ( 39576741 )
162178 expect ( ripple . resources [ 'issue' ] . headers . timestamp ) . to . be . ok
163179 expect ( issue . id ) . to . be . equal ( 39576741 )
164180 done ( )
@@ -172,12 +188,15 @@ describe('Hypermedia API', function() {
172188 var ripple = hypermedia ( data ( core ( ) ) )
173189 ripple ( 'github' , 'https://api.github.com' , { http : http } )
174190 ripple ( 'issues' , { owner : 'pemrouz' , repo : 'ripple' } , { link : 'github.repository_url.issues_url' } )
175- . on ( 'change' , function ( issues ) {
191+ . on ( 'change' , function ( change ) {
192+ var issues = change . value
193+ if ( ! ripple ( 'issues' ) . value ) return
194+ if ( ! issues . length ) return
176195 expect ( 'issues' in ripple . resources ) . to . be . ok
177196 expect ( 'github' in ripple . resources ) . to . be . ok
178197 expect ( 'github.repository_url' in ripple . resources ) . to . be . ok
179198 expect ( 'github.repository_url.issues_url' in ripple . resources ) . to . be . ok
180- expect ( ripple ( 'issues' ) . length ) . to . be . above ( 10 )
199+ expect ( ripple ( 'issues' ) . value . length ) . to . be . above ( 10 )
181200 expect ( ripple . resources [ 'issues' ] . headers . timestamp ) . to . be . ok
182201 expect ( issues . length ) . to . be . above ( 10 )
183202 done ( )
0 commit comments