Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should properly process retrieval of stored Route Handles', () => {
const strat = new CustomRouteReuseStrategy();
const testConfig2: ActivatedRouteSnapshot = {
url: [new UrlSegment('test', {})]
} as ActivatedRouteSnapshot;
const testConfig: ActivatedRouteSnapshot = {
pathFromRoot: [{}, testConfig2, {}, {}, {
url: [new UrlSegment('url', { 'id': '1' })]
}]
} as ActivatedRouteSnapshot;
// due to no route config
expect(strat.retrieve(testConfig)).toBe(null);
(testConfig as any).routeConfig = {
path: 'url'
};
// due to not existing in storage
expect(strat.retrieve(testConfig)).toBe(null);
(testConfig as any).routeConfig.loadChildren = 'fakeLoadchildren#module.module';
// due to having load children. these should never be stored.
expect(strat.retrieve(testConfig)).toBe(null);
delete (testConfig as any).routeConfig.loadChildren;
export function urlMatcher(url) {
// The expected path is :idType/:id
const idType = url[0].path;
// Allow for handles that are delimited with a forward slash.
const id = url
.slice(1)
.map((us: UrlSegment) => us.path)
.join('/');
if (isNotEmpty(idType) && isNotEmpty(id)) {
return {
consumed: url,
posParams: {
idType: new UrlSegment(idType, {}),
id: new UrlSegment(id, {})
}
};
}
return null;
}
export function urlMatcher(url) {
// The expected path is :idType/:id
const idType = url[0].path;
// Allow for handles that are delimited with a forward slash.
const id = url
.slice(1)
.map((us: UrlSegment) => us.path)
.join('/');
if (isNotEmpty(idType) && isNotEmpty(id)) {
return {
consumed: url,
posParams: {
idType: new UrlSegment(idType, {}),
id: new UrlSegment(id, {})
}
};
}
return null;
}
it('should have call content types endpoint with widget data', () => {
url = [
new UrlSegment('create', { name: 'create' }),
new UrlSegment('widget', { name: 'widget' })
];
route.url = Observable.of(url);
const mockData = [
{
clazz: 'com.dotcms.contenttype.model.type.ImmutableSimpleContentType',
defaultType: false,
fixed: false,
folder: 'SYSTEM_FOLDER',
host: '12345',
id: '1',
name: 'Hello World',
owner: '123',
system: false
}
it('should not send form with invalid data', () => {
let url = [
new UrlSegment('create', { name: 'create' }),
new UrlSegment('content', { name: 'content' })
];
route.url = Observable.of(url);
fixture.detectChanges();
let crudService = fixture.debugElement.injector.get(CrudService);
spyOn(crudService, 'postData').and.returnValue(Observable.of({}));
let mockData: ContentType = {
clazz: 'com.dotcms.contenttype.model.type.ImmutableSimpleContentType',
defaultType: false,
description: '',
detailPage: '',
fixed: false,
folder: 'SYSTEM_FOLDER',
it('renders greeting', () => {
const params = { name: 'Babel' };
const url = [new UrlSegment('ciao', params)];
const route = new ActivatedRoute(Observable.of(url), Observable.of(params));
TestBed.configureTestingModule({
declarations: [Ciao],
providers: [Greeter, { provide: ActivatedRoute, useValue: route }],
});
const fixture = TestBed.createComponent(Ciao);
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.textContent).toEqual('Ciao, Babel!');
});
});
it('should return matcher if path starts with app path root', () => {
var a = new UrlSegment('content', {});
var b = new UrlSegment('we-retail-journal', {});
var c = new UrlSegment('angular', {});
var d = new UrlSegment('foo.html', {});
var url = [a, b, c, d];
expect(AemPageMatcher(url)).toEqual({
consumed: url,
posParams: {
path: d
}
});
});
});
it('should return matcher if path starts with app path root', () => {
var a = new UrlSegment('content', {});
var b = new UrlSegment('we-retail-journal', {});
var c = new UrlSegment('angular', {});
var d = new UrlSegment('foo.html', {});
var url = [a, b, c, d];
expect(AemPageMatcher(url)).toEqual({
consumed: url,
posParams: {
path: d
}
});
});
});
beforeEach(async(() => {
const routerSpy: any = jasmine.createSpyObj('Router', ['navigate']);
const activatedRouteStub: any = new ActivatedRouteUrlStub([new UrlSegment('createbrwfrm', {})] as UrlSegment[]);
const authServiceStub: Partial = {};
authServiceStub.authSubject = new BehaviorSubject(new UserAuthInfo());
const photoService: any = jasmine.createSpyObj('PhotoService', ['loadAlbumPhoto']);
const loadAlbumPhotoSpy: any = photoService.loadAlbumPhoto.and.returnValue(of([]));
const albumService: any = jasmine.createSpyObj('AlbumService', ['loadAlbums', 'loadAlbumContainsPhoto']);
const loadAlbumsSpy: any = albumService.loadAlbums.and.returnValue(of([]));
const loadAlbumContainsPhotoSpy: any = albumService.loadAlbumContainsPhoto.and.returnValue(of([]));
TestBed.configureTestingModule({
imports: [
MatFormFieldModule,
MatCardModule,
FormsModule,
MatCheckboxModule,
MatChipsModule,
MatIconModule,
beforeEach(async(() => {
const routerSpy: any = jasmine.createSpyObj('Router', ['navigate']);
const activatedRouteStub: any = new ActivatedRouteUrlStub([new UrlSegment('create', {})] as UrlSegment[]);
const albumService: any = jasmine.createSpyObj('AlbumService', ['loadAlbum']);
const loadAlbumSpy: any = albumService.loadAlbum.and.returnValue(of([]));
const photoService: any = jasmine.createSpyObj('PhotoService', ['loadAlbumPhoto']);
const loadAlbumPhotoSpy: any = photoService.loadAlbumPhoto.and.returnValue(of([]));
TestBed.configureTestingModule({
imports: [
MatGridListModule,
MatExpansionModule,
MatDividerModule,
MatButtonModule,
MatMenuModule,
MatIconModule,
MatPaginatorModule,
MatSnackBarModule,
MatDialogModule,