@@ -205,54 +205,75 @@ describe('VocabularyTreeviewService test suite', () => {
205205 } ) ;
206206
207207 it ( 'should set initValueHierarchy' , ( ) => {
208- serviceAsAny . vocabularyService . getEntryDetailChildren . and . returnValue ( hot ( '--a' , {
209- a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ child , child2 ] ) )
208+ serviceAsAny . vocabularyService . searchTopEntries . and . returnValue ( hot ( '--a' , {
209+ a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ item , item2 , item3 ] ) )
210210 } ) ) ;
211- serviceAsAny . vocabularyService . findEntryDetailById . and . returnValues (
211+ serviceAsAny . vocabularyService . findEntryDetailById . and . returnValue (
212212 hot ( '-a' , {
213- a : createSuccessfulRemoteDataObject ( child ) ,
214- } ) ,
215- hot ( '-b' , {
216- b : createSuccessfulRemoteDataObject ( item )
213+ a : createSuccessfulRemoteDataObject ( child2 )
217214 } )
218215 ) ;
219216 serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
220217 hot ( '-b' , {
221218 b : createSuccessfulRemoteDataObject ( item )
222219 } )
223220 ) ;
224-
225- scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ ] , 'root1' ) ) ;
221+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ ] , 'root2' ) ) ;
226222 scheduler . flush ( ) ;
227223
228224 expect ( serviceAsAny . vocabularyName ) . toEqual ( vocabularyOptions . name ) ;
229- expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child1' ] ) ;
225+ expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child2' ] ) ;
226+ expect ( serviceAsAny . dataChange . value ) . toEqual ( [ itemInitNode , itemNode2 , itemNode3 ] ) ;
230227 } ) ;
231- // 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
232- xit ( 'should show only nodes restricted to init Value Hierarchy' , ( ) => {
233- serviceAsAny . vocabularyService . getEntryDetailChildren . and . returnValue ( hot ( '--a' , {
234- a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ child , child2 ] ) )
228+
229+ it ( 'should show only nodes restricted to init Value Hierarchy' , ( ) => {
230+ serviceAsAny . vocabularyService . searchTopEntries . and . returnValue ( hot ( '--a' , {
231+ a : createSuccessfulRemoteDataObject ( buildPaginatedList ( pageInfo , [ item , item2 , item3 ] ) )
235232 } ) ) ;
236- serviceAsAny . vocabularyService . findEntryDetailById . and . returnValues (
233+ serviceAsAny . vocabularyService . findEntryDetailById . and . returnValue (
237234 hot ( '-a' , {
238- a : createSuccessfulRemoteDataObject ( child ) ,
239- } ) ,
240- hot ( '-b' , {
241- b : createSuccessfulRemoteDataObject ( item )
235+ a : createSuccessfulRemoteDataObject ( child2 )
242236 } )
243237 ) ;
244238 serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
245239 hot ( '-b' , {
246240 b : createSuccessfulRemoteDataObject ( item )
247241 } )
248242 ) ;
249- scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ 'root1-child1 ' ] , 'root1-child1 ' , true ) ) ;
243+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ 'root2 ' ] , 'root2 ' , true ) ) ;
250244 scheduler . flush ( ) ;
251245
252246 expect ( serviceAsAny . vocabularyName ) . toEqual ( vocabularyOptions . name ) ;
253- expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child1 ' ] ) ;
247+ expect ( serviceAsAny . initValueHierarchy ) . toEqual ( [ 'root1' , 'root1-child2 ' ] ) ;
254248 expect ( serviceAsAny . dataChange . value ) . toEqual ( [ itemInitNode ] ) ;
255249 } ) ;
250+
251+ it ( 'should call retrieveNodesTreeByTopParentEntry properly when is a relation component' , ( ) => {
252+ serviceAsAny . vocabularyService . findEntryDetailById . and . returnValues (
253+ hot ( '-a' , {
254+ a : createSuccessfulRemoteDataObject ( child )
255+ } ) ,
256+ hot ( '-b' , {
257+ b : createSuccessfulRemoteDataObject ( item )
258+ } ) ,
259+ ) ;
260+
261+ serviceAsAny . vocabularyService . getEntryDetailChildren . and . returnValue ( hot ( '-a' , {
262+ a : createSuccessfulRemoteDataObject ( [ child ] )
263+ } ) ) ;
264+
265+ serviceAsAny . vocabularyService . getEntryDetailParent . and . returnValue (
266+ hot ( '-a' , {
267+ a : createSuccessfulRemoteDataObject ( item )
268+ } ) ,
269+ ) ;
270+ spyOn ( serviceAsAny , 'retrieveNodesTreeByTopParentEntry' ) ;
271+
272+ scheduler . schedule ( ( ) => service . initialize ( vocabularyOptions , pageInfo , [ child . id ] , child . id , false , true ) ) ;
273+ scheduler . flush ( ) ;
274+
275+ expect ( serviceAsAny . retrieveNodesTreeByTopParentEntry ) . toHaveBeenCalledWith ( child . otherInformation . parent , pageInfo , [ child . id ] ) ;
276+ } ) ;
256277 } ) ;
257278
258279 describe ( 'getData' , ( ) => {
@@ -389,4 +410,5 @@ describe('VocabularyTreeviewService test suite', () => {
389410 expect ( serviceAsAny . dataChange . value ) . toEqual ( treeNodeList ) ;
390411 } ) ;
391412 } ) ;
413+
392414} ) ;
0 commit comments