The new version of `dgeni-packages/typescript` no longer strips out "namespaces" from types, which was part of the problem of not autolinking correctly to `HttpEventType.Response`. Another part of the problem was that we did not include `.` characters when matching potential code blocks for auto-linking, which precluded properties of enums from being linked. Finally, members we not being given a `path` property, which is needed to effectively autolink to them. This is now set in the `simplifyMemberAnchors` processor. Closes #21375 PR Close #22494
		
			
				
	
	
		
			73 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const testPackage = require('../../helpers/test-package');
 | |
| const processorFactory = require('./simplifyMemberAnchors');
 | |
| const Dgeni = require('dgeni');
 | |
| 
 | |
| describe('simplifyMemberAnchors processor', () => {
 | |
| 
 | |
|   it('should be available on the injector', () => {
 | |
|     const dgeni = new Dgeni([testPackage('angular-api-package')]);
 | |
|     const injector = dgeni.configureInjector();
 | |
|     const processor = injector.get('simplifyMemberAnchors');
 | |
|     expect(processor.$process).toBeDefined();
 | |
|     expect(processor.$runAfter).toEqual(['paths-computed']);
 | |
|     expect(processor.$runBefore).toEqual(['rendering-docs']);
 | |
|   });
 | |
| 
 | |
|   describe('$process', () => {
 | |
|     describe('docs without members', () => {
 | |
|       it('should ignore the docs', () => {
 | |
|         const processor = processorFactory();
 | |
|         const docs = [
 | |
|           { id: 'some-doc' },
 | |
|           { id: 'some-other' }
 | |
|         ];
 | |
|         processor.$process(docs);
 | |
|         expect(docs).toEqual([
 | |
|           { id: 'some-doc' },
 | |
|           { id: 'some-other' }
 | |
|         ]);
 | |
|       });
 | |
|     });
 | |
| 
 | |
|     describe('docs with members', () => {
 | |
|       it('should compute an anchor for each instance member', () => {
 | |
|         const processor = processorFactory();
 | |
|         const docs = [
 | |
|           { id: 'some-doc', members: [ { name: 'foo' }, { name: 'new' }, { name: '' } ] }
 | |
|         ];
 | |
|         processor.$process(docs);
 | |
|         expect(docs[0].members.map(member => member.anchor)).toEqual(['foo', 'new', 'call']);
 | |
|       });
 | |
| 
 | |
|       it('should compute a path for each instance member', () => {
 | |
|         const processor = processorFactory();
 | |
|         const docs = [
 | |
|           { id: 'some-doc', path: 'a/b/c', members: [ { name: 'foo' }, { name: 'new' }, { name: '' } ] }
 | |
|         ];
 | |
|         processor.$process(docs);
 | |
|         expect(docs[0].members.map(member => member.path)).toEqual(['a/b/c#foo', 'a/b/c#new', 'a/b/c#call']);
 | |
|       });
 | |
|     });
 | |
| 
 | |
|     describe('docs with static members', () => {
 | |
|       it('should compute an anchor for each static member', () => {
 | |
|         const processor = processorFactory();
 | |
|         const docs = [
 | |
|           { id: 'some-doc', statics: [ { name: 'foo' }, { name: 'new' }, { name: '' } ] }
 | |
|         ];
 | |
|         processor.$process(docs);
 | |
|         expect(docs[0].statics.map(member => member.anchor)).toEqual(['foo', 'new', 'call']);
 | |
|       });
 | |
| 
 | |
|       it('should compute a path for each static member', () => {
 | |
|         const processor = processorFactory();
 | |
|         const docs = [
 | |
|           { id: 'some-doc', path: 'a/b/c', statics: [ { name: 'foo' }, { name: 'new' }, { name: '' } ] }
 | |
|         ];
 | |
|         processor.$process(docs);
 | |
|         expect(docs[0].statics.map(member => member.path)).toEqual(['a/b/c#foo', 'a/b/c#new', 'a/b/c#call']);
 | |
|       });
 | |
|     });
 | |
|   });
 | |
| });
 |