2017-04-16 15:48:22 -04:00
|
|
|
const fs = require('fs');
|
|
|
|
const {resolve} = require('canonical-path');
|
|
|
|
const {generateDocs} = require('./index.js');
|
2017-05-03 08:55:00 -04:00
|
|
|
const { DOCS_OUTPUT_PATH } = require('../config');
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
describe('authors-package', () => {
|
|
|
|
let files;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
files = [];
|
|
|
|
spyOn(fs, 'writeFile').and.callFake((file, content, callback) => {
|
|
|
|
files.push(file);
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should generate marketing docs if the "fileChanged" is a marketing doc', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('aio/content/marketing/about.html', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04: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 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-04-20 15:04:09 -04:00
|
|
|
}, 4000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate tutorial docs if the "fileChanged" is a tutorial doc', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('aio/content/tutorial/toh-pt5.md', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'tutorial/toh-pt5.json'));
|
2017-04-16 16:38:00 -04:00
|
|
|
done();
|
2017-04-16 15:48:22 -04:00
|
|
|
});
|
2017-04-20 15:04:09 -04:00
|
|
|
}, 4000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate tutorial docs if the "fileChanged" is the tutorial index', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('aio/content/tutorial/index.md', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'tutorial.json'));
|
2017-04-16 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-04-20 15:04:09 -04:00
|
|
|
}, 4000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate tutorial docs if the "fileChanged" is a tutorial example', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('aio/content/examples/toh-pt3/app/app.component.1.html', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'tutorial/toh-pt3.json'));
|
2017-04-16 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-04-20 15:04:09 -04:00
|
|
|
}, 4000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate guide doc if the "fileChanged" is a guide doc', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('aio/content/guide/architecture.md', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'guide/architecture.json'));
|
2017-04-16 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-04-20 15:04:09 -04:00
|
|
|
}, 4000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate guide doc if the "fileChanged" is a guide example', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('aio/content/examples/architecture/src/app/app.module.ts', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'guide/architecture.json'));
|
2017-04-16 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-04-20 15:04:09 -04:00
|
|
|
}, 4000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate API doc if the "fileChanged" is an API doc', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('packages/forms/src/form_builder.ts', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'api/forms/FormBuilder.json'));
|
2017-04-16 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-05-03 08:55:00 -04:00
|
|
|
}, 8000);
|
2017-04-16 15:48:22 -04:00
|
|
|
|
|
|
|
it('should generate API doc if the "fileChanged" is an API example', (done) => {
|
2017-04-21 08:10:52 -04:00
|
|
|
generateDocs('packages/examples/forms/ts/formBuilder/form_builder_example.ts', { silent: true }).then(() => {
|
2017-04-16 15:48:22 -04:00
|
|
|
expect(fs.writeFile).toHaveBeenCalled();
|
2017-05-03 08:55:00 -04:00
|
|
|
expect(files).toContain(resolve(DOCS_OUTPUT_PATH, 'api/forms/FormBuilder.json'));
|
2017-04-16 15:48:22 -04:00
|
|
|
done();
|
|
|
|
});
|
2017-05-03 08:55:00 -04:00
|
|
|
}, 8000);
|
2017-04-16 15:48:22 -04:00
|
|
|
});
|