@@ -97,6 +97,15 @@ describe(`NodeModel`, () => {
97
97
} )
98
98
} )
99
99
100
+ it ( `creates page dependency when called with context` , ( ) => {
101
+ nodeModel . withContext ( { path : `/` } ) . getNodeById ( { id : `person2` } )
102
+ expect ( createPageDependency ) . toHaveBeenCalledTimes ( 1 )
103
+ expect ( createPageDependency ) . toHaveBeenCalledWith ( {
104
+ path : `/` ,
105
+ nodeId : `person2` ,
106
+ } )
107
+ } )
108
+
100
109
it ( `returns null when no id provided` , ( ) => {
101
110
expect ( nodeModel . getNodeById ( ) ) . toBeNull ( )
102
111
expect ( nodeModel . getNodeById ( { } ) ) . toBeNull ( )
@@ -171,6 +180,21 @@ describe(`NodeModel`, () => {
171
180
} )
172
181
} )
173
182
183
+ it ( `creates page dependencies when called with context` , ( ) => {
184
+ nodeModel
185
+ . withContext ( { path : `/` } )
186
+ . getNodesByIds ( { ids : [ `person3` , `post3` ] } )
187
+ expect ( createPageDependency ) . toHaveBeenCalledTimes ( 2 )
188
+ expect ( createPageDependency ) . toHaveBeenCalledWith ( {
189
+ path : `/` ,
190
+ nodeId : `person3` ,
191
+ } )
192
+ expect ( createPageDependency ) . toHaveBeenCalledWith ( {
193
+ path : `/` ,
194
+ nodeId : `post3` ,
195
+ } )
196
+ } )
197
+
174
198
it ( `returns empty array when no ids provided` , ( ) => {
175
199
expect ( nodeModel . getNodesByIds ( ) ) . toEqual ( [ ] )
176
200
expect ( nodeModel . getNodesByIds ( { } ) ) . toEqual ( [ ] )
@@ -223,6 +247,18 @@ describe(`NodeModel`, () => {
223
247
expect ( createPageDependency ) . toHaveBeenCalledTimes ( 9 )
224
248
} )
225
249
250
+ it ( `creates page dependencies when called with context and connection type` , ( ) => {
251
+ nodeModel
252
+ . withContext ( { path : `/` } )
253
+ . getAllNodes ( { type : `Post` } , { connectionType : `Post` } )
254
+ expect ( createPageDependency ) . toHaveBeenCalledTimes ( 1 )
255
+ } )
256
+
257
+ it ( `does not create page dependencies when called with context without connection type` , ( ) => {
258
+ nodeModel . withContext ( { path : `/` } ) . getAllNodes ( )
259
+ expect ( createPageDependency ) . toHaveBeenCalledTimes ( 0 )
260
+ } )
261
+
226
262
it ( `returns empty array when no nodes of type found` , ( ) => {
227
263
const result = nodeModel . getAllNodes ( { type : `Astronauts` } )
228
264
expect ( result ) . toEqual ( [ ] )
@@ -285,6 +321,24 @@ describe(`NodeModel`, () => {
285
321
} )
286
322
} )
287
323
324
+ it ( `creates page dependencies when called with context` , async ( ) => {
325
+ const type = `Post`
326
+ const query = { filter : { frontmatter : { published : { eq : false } } } }
327
+ const firstOnly = false
328
+ await nodeModel
329
+ . withContext ( { path : `/` } )
330
+ . runQuery ( { query, firstOnly, type } )
331
+ expect ( createPageDependency ) . toHaveBeenCalledTimes ( 2 )
332
+ expect ( createPageDependency ) . toHaveBeenCalledWith ( {
333
+ path : `/` ,
334
+ nodeId : `post1` ,
335
+ } )
336
+ expect ( createPageDependency ) . toHaveBeenCalledWith ( {
337
+ path : `/` ,
338
+ nodeId : `post3` ,
339
+ } )
340
+ } )
341
+
288
342
it ( `creates page dependencies with connection type` , async ( ) => {
289
343
const type = `Post`
290
344
const query = { filter : { frontmatter : { published : { eq : false } } } }
0 commit comments