@@ -178,8 +178,10 @@ describe('relationship utils', () => {
178178 describe ( 'linkRelatedModels()' , function ( ) {
179179 it ( 'belongsTo' , ( ) => {
180180 setupBelongsTo ( )
181+ const from = { model : Comment , id : 1 }
182+ const to = { model : Post , data : 1 }
181183 return Comment . create ( { } , { } )
182- . then ( ( ) => linkRelatedModels ( 'post' , Comment , 1 , Post , 1 ) )
184+ . then ( ( ) => linkRelatedModels ( 'post' , from , to ) )
183185 . then ( ( ) => Comment . find ( { where : { postId : 1 } } ) )
184186 . then ( comments => {
185187 expect ( comments . length ) . to . equal ( 1 )
@@ -188,8 +190,10 @@ describe('relationship utils', () => {
188190 } )
189191 it ( 'hasMany' , ( ) => {
190192 setupHasMany ( )
193+ const from = { model : Post , id : 1 }
194+ const to = { model : Comment , data : [ 2 , 3 , 4 ] }
191195 return Comment . create ( [ { postId : 1 } , { postId : 1 } , { postId : 1 } , { } ] )
192- . then ( ( ) => linkRelatedModels ( 'comments' , Post , 1 , Comment , [ 2 , 3 , 4 ] ) )
196+ . then ( ( ) => linkRelatedModels ( 'comments' , from , to ) )
193197 . then ( ( ) => Comment . find ( { where : { postId : 1 } } ) )
194198 . then ( comments => {
195199 expect ( comments . length ) . to . equal ( 3 )
@@ -200,6 +204,8 @@ describe('relationship utils', () => {
200204 } )
201205 it ( 'hasManyThrough' , ( ) => {
202206 setupHasManyThrough ( )
207+ const from = { model : Post , id : 1 }
208+ const to = { model : Comment , data : [ 2 , 3 , 4 ] }
203209 return Promise . all ( [
204210 Post . create ( { } ) ,
205211 Comment . create ( [ { } , { } , { } , { } ] ) ,
@@ -209,7 +215,7 @@ describe('relationship utils', () => {
209215 { postId : 1 , commentId : 3 }
210216 ] )
211217 ] )
212- . then ( ( ) => linkRelatedModels ( 'comments' , Post , 1 , Comment , [ 2 , 3 , 4 ] ) )
218+ . then ( ( ) => linkRelatedModels ( 'comments' , from , to ) )
213219 . then ( ( ) => PostComment . find ( { where : { postId : 1 } } ) )
214220 . then ( postComments => {
215221 expect ( postComments . length ) . to . equal ( 3 )
@@ -220,8 +226,10 @@ describe('relationship utils', () => {
220226 } )
221227 it ( 'hasOne' , ( ) => {
222228 setupHasOne ( )
229+ const from = { model : Post , id : 1 }
230+ const to = { model : Comment , data : 1 }
223231 return Comment . create ( [ { } , { } ] )
224- . then ( ( ) => linkRelatedModels ( 'comment' , Post , 1 , Comment , 1 ) )
232+ . then ( ( ) => linkRelatedModels ( 'comment' , from , to ) )
225233 . then ( ( ) => Comment . find ( { where : { postId : 1 } } ) )
226234 . then ( comments => {
227235 expect ( comments . length ) . to . equal ( 1 )
@@ -230,8 +238,10 @@ describe('relationship utils', () => {
230238 } )
231239 it ( 'hasOne null' , ( ) => {
232240 setupHasOne ( )
241+ const from = { model : Post , id : 1 }
242+ const to = { model : Comment , data : null }
233243 return Comment . create ( [ { postId : 1 } ] )
234- . then ( ( ) => linkRelatedModels ( 'comment' , Post , 1 , Comment , null ) )
244+ . then ( ( ) => linkRelatedModels ( 'comment' , from , to ) )
235245 . then ( ( ) => Comment . find ( { where : { postId : null } } ) )
236246 . then ( comments => {
237247 expect ( comments . length ) . to . equal ( 1 )
0 commit comments