|
| 1 | +import { expect } from 'chai'; |
| 2 | +import { temporaryDir, shell, exists, read } from '../helpers'; |
| 3 | + |
| 4 | +const tmp = temporaryDir(); |
| 5 | + |
| 6 | +describe('CLI issue #623 - barrel spread declarations', () => { |
| 7 | + const distFolder = tmp.name + '-issue-623-barrel-spread'; |
| 8 | + let documentation: any; |
| 9 | + |
| 10 | + before(function (done) { |
| 11 | + tmp.create(distFolder); |
| 12 | + const ls = shell('node', [ |
| 13 | + './bin/index-cli.js', |
| 14 | + '-p', |
| 15 | + './test/fixtures/issue623-barrel-spread/tsconfig.json', |
| 16 | + '-e', |
| 17 | + 'json', |
| 18 | + '-d', |
| 19 | + distFolder, |
| 20 | + ]); |
| 21 | + |
| 22 | + if (ls.stderr.toString() !== '') { |
| 23 | + console.error(`shell error: ${ls.stderr.toString()}`); |
| 24 | + done('error'); |
| 25 | + return; |
| 26 | + } |
| 27 | + |
| 28 | + documentation = JSON.parse(read(`${distFolder}/documentation.json`)); |
| 29 | + done(); |
| 30 | + }); |
| 31 | + |
| 32 | + after(() => tmp.clean(distFolder)); |
| 33 | + |
| 34 | + it('should generate documentation successfully', () => { |
| 35 | + expect(exists(distFolder)).to.be.true; |
| 36 | + }); |
| 37 | + |
| 38 | + it('should resolve declarations from namespace barrel spread', () => { |
| 39 | + const appModule = documentation.modules.find( |
| 40 | + (module) => module.name === 'AppModule', |
| 41 | + ); |
| 42 | + const declarations = appModule.children.find( |
| 43 | + (child) => child.type === 'declarations', |
| 44 | + ).elements; |
| 45 | + |
| 46 | + const declarationNames = declarations.map((entry) => entry.name); |
| 47 | + |
| 48 | + expect(declarationNames).to.include('RegistrationRootComponent'); |
| 49 | + expect(declarationNames).to.include('AccountTypeComponent'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should resolve exports from namespace barrel spread', () => { |
| 53 | + const appModule = documentation.modules.find( |
| 54 | + (module) => module.name === 'AppModule', |
| 55 | + ); |
| 56 | + const exportsElements = appModule.children.find( |
| 57 | + (child) => child.type === 'exports', |
| 58 | + ).elements; |
| 59 | + |
| 60 | + const exportNames = exportsElements.map((entry) => entry.name); |
| 61 | + |
| 62 | + expect(exportNames).to.include('RegistrationRootComponent'); |
| 63 | + expect(exportNames).to.include('AccountTypeComponent'); |
| 64 | + }); |
| 65 | +}); |
0 commit comments