| 
									
										
										
										
											2017-10-25 15:02:01 +01:00
										 |  |  | /* eslint jasmine/prefer-toHaveBeenCalledWith:0 */ | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | const fs = require('fs'); | 
					
						
							|  |  |  | const {resolve} = require('canonical-path'); | 
					
						
							|  |  |  | const {generateDocs} = require('./index.js'); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  | const { DOCS_OUTPUT_PATH } = require('../config'); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 11:42:36 +01:00
										 |  |  | describe('authors-package (integration tests)', () => { | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   let originalJasmineTimeout; | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |   let files; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   beforeAll(() => { | 
					
						
							|  |  |  |     originalJasmineTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | 
					
						
							|  |  |  |     jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-02-23 14:16:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalJasmineTimeout); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |   beforeEach(() => { | 
					
						
							|  |  |  |     files = []; | 
					
						
							|  |  |  |     spyOn(fs, 'writeFile').and.callFake((file, content, callback) => { | 
					
						
							|  |  |  |       files.push(file); | 
					
						
							|  |  |  |       callback(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate marketing docs if the "fileChanged" is a marketing doc', () => { | 
					
						
							|  |  |  |     return generateDocs('aio/content/marketing/about.html', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'about.json')); | 
					
						
							|  |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, '../navigation.json')); | 
					
						
							|  |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, '../contributors.json')); | 
					
						
							|  |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, '../resources.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate tutorial docs if the "fileChanged" is a tutorial doc', () => { | 
					
						
							|  |  |  |     return generateDocs('aio/content/tutorial/toh-pt5.md', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'tutorial/toh-pt5.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate tutorial docs if the "fileChanged" is the tutorial index', () => { | 
					
						
							|  |  |  |     return generateDocs('aio/content/tutorial/index.md', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'tutorial.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate tutorial docs if the "fileChanged" is a tutorial example', () => { | 
					
						
							|  |  |  |     return generateDocs('aio/content/examples/toh-pt3/app/app.component.1.html', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'tutorial/toh-pt3.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate guide doc if the "fileChanged" is a guide doc', () => { | 
					
						
							|  |  |  |     return generateDocs('aio/content/guide/architecture.md', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'guide/architecture.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate guide doc if the "fileChanged" is a guide example', () => { | 
					
						
							|  |  |  |     return generateDocs('aio/content/examples/architecture/src/app/app.module.ts', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'guide/architecture.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate API doc if the "fileChanged" is an API doc', () => { | 
					
						
							|  |  |  |     return generateDocs('packages/forms/src/form_builder.ts', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'api/forms/FormBuilder.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-06-13 11:42:36 +01:00
										 |  |  |   }, 16000); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-03 11:48:45 +01:00
										 |  |  |   it('should generate API doc if the "fileChanged" is an API example', () => { | 
					
						
							|  |  |  |     return generateDocs('packages/examples/forms/ts/formBuilder/form_builder_example.ts', { silent: true }).then(() => { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |       expect(fs.writeFile).toHaveBeenCalled(); | 
					
						
							| 
									
										
										
										
											2017-05-03 13:55:00 +01:00
										 |  |  |       expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'api/forms/FormBuilder.json')); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-06-13 11:42:36 +01:00
										 |  |  |   }, 16000); | 
					
						
							| 
									
										
										
										
											2018-02-16 21:17:07 +02:00
										 |  |  | }); |