|
|
|
@ -7,7 +7,11 @@ import { NEVER } from 'rxjs'; |
|
|
|
import { DynamicLayoutComponent, RouterOutletComponent } from '../components'; |
|
|
|
import { eLayoutType } from '../enums/common'; |
|
|
|
import { ABP } from '../models'; |
|
|
|
import { ApplicationConfigurationService, RoutesService } from '../services'; |
|
|
|
import { |
|
|
|
ApplicationConfigurationService, |
|
|
|
RoutesService, |
|
|
|
ReplaceableComponentsService, |
|
|
|
} from '../services'; |
|
|
|
import { ReplaceableComponentsState } from '../states'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
@ -78,33 +82,7 @@ const routes: ABP.Route[] = [ |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
const storeData = { |
|
|
|
ReplaceableComponentsState: { |
|
|
|
replaceableComponents: [ |
|
|
|
{ |
|
|
|
key: 'Theme.ApplicationLayoutComponent', |
|
|
|
component: DummyApplicationLayoutComponent, |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: 'Theme.AccountLayoutComponent', |
|
|
|
component: DummyAccountLayoutComponent, |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: 'Theme.EmptyLayoutComponent', |
|
|
|
component: DummyEmptyLayoutComponent, |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
describe('DynamicLayoutComponent', () => { |
|
|
|
const mockActions: Actions = NEVER; |
|
|
|
const mockStore = ({ |
|
|
|
selectSnapshot() { |
|
|
|
return true; |
|
|
|
}, |
|
|
|
} as unknown) as Store; |
|
|
|
|
|
|
|
const createComponent = createRoutingFactory({ |
|
|
|
component: RouterOutletComponent, |
|
|
|
stubsEnabled: false, |
|
|
|
@ -113,10 +91,16 @@ describe('DynamicLayoutComponent', () => { |
|
|
|
providers: [ |
|
|
|
{ |
|
|
|
provide: RoutesService, |
|
|
|
useFactory: () => new RoutesService(mockActions, mockStore), |
|
|
|
useFactory: () => |
|
|
|
new RoutesService(NEVER, ({ |
|
|
|
selectSnapshot() { |
|
|
|
return true; |
|
|
|
}, |
|
|
|
} as unknown) as Store), |
|
|
|
}, |
|
|
|
ReplaceableComponentsService, |
|
|
|
], |
|
|
|
imports: [RouterModule, DummyLayoutModule, NgxsModule.forRoot([ReplaceableComponentsState])], |
|
|
|
imports: [RouterModule, DummyLayoutModule, NgxsModule.forRoot()], |
|
|
|
routes: [ |
|
|
|
{ path: '', component: RouterOutletComponent }, |
|
|
|
{ |
|
|
|
@ -163,15 +147,26 @@ describe('DynamicLayoutComponent', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
let spectator: SpectatorRouting<RouterOutletComponent>; |
|
|
|
let store: Store; |
|
|
|
let replaceableComponents: ReplaceableComponentsService; |
|
|
|
|
|
|
|
beforeEach(async () => { |
|
|
|
spectator = createComponent(); |
|
|
|
store = spectator.inject(Store); |
|
|
|
replaceableComponents = spectator.inject(ReplaceableComponentsService); |
|
|
|
const routesService = spectator.inject(RoutesService); |
|
|
|
routesService.add(routes); |
|
|
|
|
|
|
|
store.reset(storeData); |
|
|
|
replaceableComponents.add({ |
|
|
|
key: 'Theme.ApplicationLayoutComponent', |
|
|
|
component: DummyApplicationLayoutComponent, |
|
|
|
}); |
|
|
|
replaceableComponents.add({ |
|
|
|
key: 'Theme.AccountLayoutComponent', |
|
|
|
component: DummyAccountLayoutComponent, |
|
|
|
}); |
|
|
|
replaceableComponents.add({ |
|
|
|
key: 'Theme.EmptyLayoutComponent', |
|
|
|
component: DummyEmptyLayoutComponent, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should handle application layout from parent abp route and display it', async () => { |
|
|
|
@ -204,8 +199,8 @@ describe('DynamicLayoutComponent', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not display any layout when layouts are empty', async () => { |
|
|
|
store.reset({ ...storeData, ReplaceableComponentsState: {} }); |
|
|
|
|
|
|
|
const spy = jest.spyOn(replaceableComponents, 'get'); |
|
|
|
spy.mockReturnValue(null); |
|
|
|
spectator.detectChanges(); |
|
|
|
|
|
|
|
spectator.router.navigateByUrl('/withoutLayout'); |
|
|
|
|