@@ -224,28 +224,47 @@ describe('VocabularyTreeviewService test suite', () => {
224224 } ) ;
225225
226226 it ( 'should set initValueHierarchy' , ( ) => {
227- serviceAsAny . vocabularyService . getEntryDetailChildren . and . returnValue ( hot ( '--a' , {
228- a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ child , child2 ] ) ) ,
227+ serviceAsAny . vocabularyService . searchTopEntries . and . returnValue ( hot ( '--a' , {
228+ a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ item , item2 , item3 ] ) ) ,
229229 } ) ) ;
230- serviceAsAny . vocabularyService . findEntryDetailById . and . returnValues (
230+ serviceAsAny . vocabularyService . findEntryDetailById . and . returnValue (
231231 hot ( '-a' , {
232- a : createSuccessfulRemoteDataObject ( child ) ,
232+ a : createSuccessfulRemoteDataObject ( child2 ) ,
233233 } ) ,
234+ ) ;
235+ serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
234236 hot ( '-b' , {
235237 b : createSuccessfulRemoteDataObject ( item ) ,
236238 } ) ,
237239 ) ;
240+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ ] , 'root2' ) ) ;
241+ scheduler . flush ( ) ;
242+
243+ expect ( serviceAsAny . vocabularyName ) . toEqual ( vocabularyOptions . name ) ;
244+ expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child2' ] ) ;
245+ expect ( serviceAsAny . dataChange . value ) . toEqual ( [ itemInitNode , itemNode2 , itemNode3 ] ) ;
246+ } ) ;
247+
248+ it ( 'should show only nodes restricted to init Value Hierarchy' , ( ) => {
249+ serviceAsAny . vocabularyService . searchTopEntries . and . returnValue ( hot ( '--a' , {
250+ a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ item , item2 , item3 ] ) ) ,
251+ } ) ) ;
252+ serviceAsAny . vocabularyService . findEntryDetailById . and . returnValue (
253+ hot ( '-a' , {
254+ a : createSuccessfulRemoteDataObject ( child2 ) ,
255+ } ) ,
256+ ) ;
238257 serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
239258 hot ( '-b' , {
240259 b : createSuccessfulRemoteDataObject ( item ) ,
241260 } ) ,
242261 ) ;
243-
244- scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ ] , 'root1' ) ) ;
262+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ 'root2' ] , 'root2' , true ) ) ;
245263 scheduler . flush ( ) ;
246264
247265 expect ( serviceAsAny . vocabularyName ) . toEqual ( vocabularyOptions . name ) ;
248- expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child1' ] ) ;
266+ expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child2' ] ) ;
267+ expect ( serviceAsAny . dataChange . value ) . toEqual ( [ itemInitNode ] ) ;
249268 } ) ;
250269 // Disabled as we don't limt the tree anymore to the first value of the hierarchy but we start building the tree directly from that one (root node) for any case
251270 xit ( 'should show only nodes restricted to init Value Hierarchy' , ( ) => {
@@ -254,24 +273,48 @@ describe('VocabularyTreeviewService test suite', () => {
254273 } ) ) ;
255274 serviceAsAny . vocabularyService . findEntryDetailById . and . returnValues (
256275 hot ( '-a' , {
257- a : createSuccessfulRemoteDataObject ( child ) ,
258- } ) ,
259- hot ( '-b' , {
260- b : createSuccessfulRemoteDataObject ( item ) ,
276+ a : createSuccessfulRemoteDataObject ( child2 ) ,
261277 } ) ,
262278 ) ;
263279 serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
264280 hot ( '-b' , {
265281 b : createSuccessfulRemoteDataObject ( item ) ,
266282 } ) ,
267283 ) ;
268- scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ 'root1-child1 ' ] , 'root1-child1 ' , true ) ) ;
284+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ 'root2 ' ] , 'root2 ' , true ) ) ;
269285 scheduler . flush ( ) ;
270286
271287 expect ( serviceAsAny . vocabularyName ) . toEqual ( vocabularyOptions . name ) ;
272- expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child1 ' ] ) ;
288+ expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child2 ' ] ) ;
273289 expect ( serviceAsAny . dataChange . value ) . toEqual ( [ itemInitNode ] ) ;
274290 } ) ;
291+
292+ it ( 'should call retrieveNodesTreeByTopParentEntry properly when is a relation component' , ( ) => {
293+ serviceAsAny . vocabularyService . findEntryDetailById . and . returnValues (
294+ hot ( '-a' , {
295+ a : createSuccessfulRemoteDataObject ( child ) ,
296+ } ) ,
297+ hot ( '-b' , {
298+ b : createSuccessfulRemoteDataObject ( item ) ,
299+ } ) ,
300+ ) ;
301+
302+ serviceAsAny . vocabularyService . getEntryDetailChildren . and . returnValue ( hot ( '-a' , {
303+ a : createSuccessfulRemoteDataObject ( [ child ] ) ,
304+ } ) ) ;
305+
306+ serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
307+ hot ( '-a' , {
308+ a : createSuccessfulRemoteDataObject ( item ) ,
309+ } ) ,
310+ ) ;
311+ spyOn ( serviceAsAny , 'retrieveNodesTreeByTopParentEntry' ) ;
312+
313+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ child . id ] , child . id , false , true ) ) ;
314+ scheduler . flush ( ) ;
315+
316+ expect ( serviceAsAny . retrieveNodesTreeByTopParentEntry ) . toHaveBeenCalledWith ( child . otherInformation . parent , pageInfo , [ child . id ] ) ;
317+ } ) ;
275318 } ) ;
276319
277320 describe ( 'getData' , ( ) => {
0 commit comments