@ -4,19 +4,27 @@ import {
LocalizationPipe ,
LocalizationPipe ,
RouterOutletComponent ,
RouterOutletComponent ,
RoutesService ,
RoutesService ,
LocalizationService ,
} from '@abp/ng.core' ;
} from '@abp/ng.core' ;
import { HttpClient , HttpClientModule } from '@angular/common/http' ;
import { HttpClient , HttpClientModule } from '@angular/common/http' ;
import { RouterModule } from '@angular/router' ;
import { RouterModule } from '@angular/router' ;
import { createRoutingFactory , SpectatorRouting } from '@ngneat/spectator/jest' ;
import { createRoutingFactory , SpectatorRouting } from '@ngneat/spectator/jest' ;
// eslint-disable-next-line @nx/enforce-module-boundaries
import { mockRoutesService } from '../../../../core/src/lib/tests/routes.service.spec' ;
import { BreadcrumbComponent , BreadcrumbItemsComponent } from '../components' ;
import { BreadcrumbComponent , BreadcrumbItemsComponent } from '../components' ;
import { OTHERS_GROUP } from '@abp/ng.core' ;
import { SORT_COMPARE_FUNC } from '@abp/ng.core' ;
const mockRoutes : ABP.Route [ ] = [
const mockRoutes : ABP.Route [ ] = [
{ name : 'Identity' , path : '/identity' } ,
{ name : 'Identity' , path : '/identity' } ,
{ name : 'Users' , path : '/identity/users' , parentName : 'Identity' } ,
{ name : 'Users' , path : '/identity/users' , parentName : 'Identity' } ,
] ;
] ;
// Simple compare function that doesn't use inject()
const simpleCompareFunc = ( a : any , b : any ) = > {
const aNumber = a . order || 0 ;
const bNumber = b . order || 0 ;
return aNumber - bNumber ;
} ;
describe ( 'BreadcrumbComponent' , ( ) = > {
describe ( 'BreadcrumbComponent' , ( ) = > {
let spectator : SpectatorRouting < RouterOutletComponent > ;
let spectator : SpectatorRouting < RouterOutletComponent > ;
let routes : RoutesService ;
let routes : RoutesService ;
@ -27,10 +35,27 @@ describe('BreadcrumbComponent', () => {
detectChanges : false ,
detectChanges : false ,
mocks : [ HttpClient ] ,
mocks : [ HttpClient ] ,
providers : [
providers : [
{ provide : CORE_OPTIONS , useValue : { } } ,
{
provide : CORE_OPTIONS ,
useValue : {
environment : {
apis : {
default : {
url : 'http://localhost:4200' ,
} ,
} ,
} ,
}
} ,
RoutesService ,
LocalizationService ,
{
provide : OTHERS_GROUP ,
useValue : 'AbpUi::OthersGroup' ,
} ,
{
{
provide : RoutesService ,
provide : SORT_COMPARE_FUNC ,
useFactory : ( ) = > mockRoutesService ( ) ,
useValue : simpleCompareFunc ,
} ,
} ,
] ,
] ,
declarations : [ ] ,
declarations : [ ] ,