Adds the ability to expose global symbols in the API docs via the `@globalApi` tag. Also supports optionally setting a namespace which will be added to the name automatically (e.g. `foo` will be renamed to `ng.foo`). Relevant APIs should also be exported through the `global.ts` file which will show up under `core/global`. PR Close #34237
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const testPackage = require('../../helpers/test-package');
 | |
| const processorFactory = require('./updateGlobalApiPath');
 | |
| const Dgeni = require('dgeni');
 | |
| 
 | |
| describe('updateGlobalApiPath processor', () => {
 | |
|   it('should be available on the injector', () => {
 | |
|     const dgeni = new Dgeni([testPackage('angular-api-package')]);
 | |
|     const injector = dgeni.configureInjector();
 | |
|     const processor = injector.get('updateGlobalApiPathProcessor');
 | |
|     expect(processor.$process).toBeDefined();
 | |
|   });
 | |
| 
 | |
|   it('should run before the correct processor', () => {
 | |
|     const processor = processorFactory();
 | |
|     expect(processor.$runBefore).toEqual(['processNgModuleDocs']);
 | |
|   });
 | |
| 
 | |
|   it('should run after the correct processor', () => {
 | |
|     const processor = processorFactory();
 | |
|     expect(processor.$runAfter).toEqual(['computePathsProcessor']);
 | |
|   });
 | |
| 
 | |
|   it('should update the paths of namespaced global APIs', () => {
 | |
|     const processor = processorFactory();
 | |
|     const docs = [{
 | |
|       docType: 'function',
 | |
|       moduleDoc: { moduleFolder: 'folder' },
 | |
|       name: 'ng.withNamespace',
 | |
|       globalNamespace: 'ng',
 | |
|       unprefixedName: 'withNamespace',
 | |
|       global: true
 | |
|     }];
 | |
|     processor.$process(docs);
 | |
|     expect(docs[0].path).toBe('folder/ngWithNamespace');
 | |
|     expect(docs[0].outputPath).toBe('folder/ngWithNamespace.json');
 | |
|   });
 | |
| });
 |