mirror of https://github.com/abpframework/abp.git
4 changed files with 351 additions and 9 deletions
@ -0,0 +1,343 @@ |
|||||
|
import { RouterTestingModule } from '@angular/router/testing'; |
||||
|
import { createServiceFactory, SpectatorService } from '@ngneat/spectator'; |
||||
|
import { NGXS_PLUGINS, NgxsModule, InitState, Store } from '@ngxs/store'; |
||||
|
import { environment } from '../../../../../apps/dev-app/src/environments/environment'; |
||||
|
import { LAYOUTS } from '../../../../theme-basic/src/public-api'; |
||||
|
import { ABP } from '../models'; |
||||
|
import { ConfigPlugin, NGXS_CONFIG_PLUGIN_OPTIONS, ABP_ROUTES } from '../plugins'; |
||||
|
import { RouterOutletComponent } from '../components'; |
||||
|
import { ConfigState } from '../states'; |
||||
|
import { CoreModule } from '../core.module'; |
||||
|
import { eLayoutType } from '../enums/common'; |
||||
|
|
||||
|
ABP_ROUTES.push( |
||||
|
{ |
||||
|
name: 'AbpUiNavigation::Menu:Administration', |
||||
|
path: '', |
||||
|
order: 1, |
||||
|
wrapper: true, |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpIdentity::Menu:IdentityManagement', |
||||
|
path: 'identity', |
||||
|
order: 1, |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: eLayoutType.application, |
||||
|
iconClass: 'fa fa-id-card-o', |
||||
|
children: [ |
||||
|
{ path: 'roles', name: 'AbpIdentity::Roles', order: 2, requiredPolicy: 'AbpIdentity.Roles' }, |
||||
|
{ path: 'users', name: 'AbpIdentity::Users', order: 1, requiredPolicy: 'AbpIdentity.Users' }, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpAccount::Menu:Account', |
||||
|
path: 'account', |
||||
|
invisible: true, |
||||
|
layout: eLayoutType.application, |
||||
|
children: [ |
||||
|
{ path: 'login', name: 'AbpAccount::Login', order: 1 }, |
||||
|
{ path: 'register', name: 'AbpAccount::Register', order: 2 }, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpTenantManagement::Menu:TenantManagement', |
||||
|
path: 'tenant-management', |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: eLayoutType.application, |
||||
|
iconClass: 'fa fa-users', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'tenants', |
||||
|
name: 'AbpTenantManagement::Tenants', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpTenantManagement.Tenants', |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
); |
||||
|
|
||||
|
const expectedState = { |
||||
|
environment, |
||||
|
requirements: { |
||||
|
layouts: LAYOUTS, |
||||
|
}, |
||||
|
routes: [ |
||||
|
{ |
||||
|
name: '::Menu:Home', |
||||
|
path: '', |
||||
|
children: [], |
||||
|
url: '/', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpAccount::Menu:Account', |
||||
|
path: 'account', |
||||
|
invisible: true, |
||||
|
layout: 'application', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'login', |
||||
|
name: 'AbpAccount::Login', |
||||
|
order: 1, |
||||
|
url: '/account/login', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'register', |
||||
|
name: 'AbpAccount::Register', |
||||
|
order: 2, |
||||
|
url: '/account/register', |
||||
|
}, |
||||
|
], |
||||
|
url: '/account', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpUiNavigation::Menu:Administration', |
||||
|
path: '', |
||||
|
order: 1, |
||||
|
wrapper: true, |
||||
|
children: [ |
||||
|
{ |
||||
|
name: 'AbpIdentity::Menu:IdentityManagement', |
||||
|
path: 'identity', |
||||
|
order: 1, |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: 'application', |
||||
|
iconClass: 'fa fa-id-card-o', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'users', |
||||
|
name: 'AbpIdentity::Users', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpIdentity.Users', |
||||
|
url: '/identity/users', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'roles', |
||||
|
name: 'AbpIdentity::Roles', |
||||
|
order: 2, |
||||
|
requiredPolicy: 'AbpIdentity.Roles', |
||||
|
url: '/identity/roles', |
||||
|
}, |
||||
|
], |
||||
|
url: '/identity', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpTenantManagement::Menu:TenantManagement', |
||||
|
path: 'tenant-management', |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: 'application', |
||||
|
iconClass: 'fa fa-users', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'tenants', |
||||
|
name: 'AbpTenantManagement::Tenants', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpTenantManagement.Tenants', |
||||
|
url: '/tenant-management/tenants', |
||||
|
}, |
||||
|
], |
||||
|
url: '/tenant-management', |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
], |
||||
|
flattedRoutes: [ |
||||
|
{ |
||||
|
name: '::Menu:Home', |
||||
|
path: '', |
||||
|
children: [], |
||||
|
url: '/', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpAccount::Menu:Account', |
||||
|
path: 'account', |
||||
|
invisible: true, |
||||
|
layout: 'application', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'login', |
||||
|
name: 'AbpAccount::Login', |
||||
|
order: 1, |
||||
|
url: '/account/login', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'register', |
||||
|
name: 'AbpAccount::Register', |
||||
|
order: 2, |
||||
|
url: '/account/register', |
||||
|
}, |
||||
|
], |
||||
|
url: '/account', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'login', |
||||
|
name: 'AbpAccount::Login', |
||||
|
order: 1, |
||||
|
url: '/account/login', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'register', |
||||
|
name: 'AbpAccount::Register', |
||||
|
order: 2, |
||||
|
url: '/account/register', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpUiNavigation::Menu:Administration', |
||||
|
path: '', |
||||
|
order: 1, |
||||
|
wrapper: true, |
||||
|
children: [ |
||||
|
{ |
||||
|
name: 'AbpIdentity::Menu:IdentityManagement', |
||||
|
path: 'identity', |
||||
|
order: 1, |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: 'application', |
||||
|
iconClass: 'fa fa-id-card-o', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'users', |
||||
|
name: 'AbpIdentity::Users', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpIdentity.Users', |
||||
|
url: '/identity/users', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'roles', |
||||
|
name: 'AbpIdentity::Roles', |
||||
|
order: 2, |
||||
|
requiredPolicy: 'AbpIdentity.Roles', |
||||
|
url: '/identity/roles', |
||||
|
}, |
||||
|
], |
||||
|
url: '/identity', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpTenantManagement::Menu:TenantManagement', |
||||
|
path: 'tenant-management', |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: 'application', |
||||
|
iconClass: 'fa fa-users', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'tenants', |
||||
|
name: 'AbpTenantManagement::Tenants', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpTenantManagement.Tenants', |
||||
|
url: '/tenant-management/tenants', |
||||
|
}, |
||||
|
], |
||||
|
url: '/tenant-management', |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpIdentity::Menu:IdentityManagement', |
||||
|
path: 'identity', |
||||
|
order: 1, |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: 'application', |
||||
|
iconClass: 'fa fa-id-card-o', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'users', |
||||
|
name: 'AbpIdentity::Users', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpIdentity.Users', |
||||
|
url: '/identity/users', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'roles', |
||||
|
name: 'AbpIdentity::Roles', |
||||
|
order: 2, |
||||
|
requiredPolicy: 'AbpIdentity.Roles', |
||||
|
url: '/identity/roles', |
||||
|
}, |
||||
|
], |
||||
|
url: '/identity', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'users', |
||||
|
name: 'AbpIdentity::Users', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpIdentity.Users', |
||||
|
url: '/identity/users', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'roles', |
||||
|
name: 'AbpIdentity::Roles', |
||||
|
order: 2, |
||||
|
requiredPolicy: 'AbpIdentity.Roles', |
||||
|
url: '/identity/roles', |
||||
|
}, |
||||
|
{ |
||||
|
name: 'AbpTenantManagement::Menu:TenantManagement', |
||||
|
path: 'tenant-management', |
||||
|
parentName: 'AbpUiNavigation::Menu:Administration', |
||||
|
layout: 'application', |
||||
|
iconClass: 'fa fa-users', |
||||
|
children: [ |
||||
|
{ |
||||
|
path: 'tenants', |
||||
|
name: 'AbpTenantManagement::Tenants', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpTenantManagement.Tenants', |
||||
|
url: '/tenant-management/tenants', |
||||
|
}, |
||||
|
], |
||||
|
url: '/tenant-management', |
||||
|
}, |
||||
|
{ |
||||
|
path: 'tenants', |
||||
|
name: 'AbpTenantManagement::Tenants', |
||||
|
order: 1, |
||||
|
requiredPolicy: 'AbpTenantManagement.Tenants', |
||||
|
url: '/tenant-management/tenants', |
||||
|
}, |
||||
|
], |
||||
|
}; |
||||
|
|
||||
|
describe('ConfigPlugin', () => { |
||||
|
let spectator: SpectatorService<ConfigPlugin>; |
||||
|
const createService = createServiceFactory({ |
||||
|
service: ConfigPlugin, |
||||
|
imports: [ |
||||
|
CoreModule, |
||||
|
NgxsModule.forRoot([]), |
||||
|
RouterTestingModule.withRoutes([ |
||||
|
{ |
||||
|
path: '', |
||||
|
component: RouterOutletComponent, |
||||
|
data: { |
||||
|
routes: { |
||||
|
name: '::Menu:Home', |
||||
|
} as ABP.Route, |
||||
|
}, |
||||
|
}, |
||||
|
{ path: 'identity', component: RouterOutletComponent }, |
||||
|
{ path: 'account', component: RouterOutletComponent }, |
||||
|
{ path: 'tenant-management', component: RouterOutletComponent }, |
||||
|
]), |
||||
|
], |
||||
|
providers: [ |
||||
|
{ |
||||
|
provide: NGXS_PLUGINS, |
||||
|
useClass: ConfigPlugin, |
||||
|
multi: true, |
||||
|
}, |
||||
|
{ |
||||
|
provide: NGXS_CONFIG_PLUGIN_OPTIONS, |
||||
|
useValue: { environment, requirements: { layouts: LAYOUTS } } as ABP.Root, |
||||
|
}, |
||||
|
], |
||||
|
}); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
spectator = createService(); |
||||
|
}); |
||||
|
|
||||
|
it('should ConfigState must be create with correct datas', () => { |
||||
|
const store = spectator.get(Store); |
||||
|
const state = store.selectSnapshot(ConfigState); |
||||
|
expect(state).toEqual(expectedState); |
||||
|
}); |
||||
|
}); |
||||
Loading…
Reference in new issue