2018-01-21 12:24:05 -05:00
|
|
|
var testPackage = require('../../helpers/test-package');
|
|
|
|
var Dgeni = require('dgeni');
|
|
|
|
|
|
|
|
describe('createSitemap processor', () => {
|
|
|
|
var injector, processor;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const dgeni = new Dgeni([testPackage('angular-base-package')]);
|
|
|
|
|
|
|
|
injector = dgeni.configureInjector();
|
|
|
|
processor = injector.get('createSitemap');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be available from the injector', () => {
|
|
|
|
expect(processor).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should run after "paths-computed"', () => {
|
|
|
|
expect(processor.$runAfter).toEqual(['paths-computed']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should run before "rendering-docs"', () => {
|
|
|
|
expect(processor.$runBefore).toEqual(['rendering-docs']);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('$process', () => {
|
|
|
|
describe('should add a sitemap doc', () => {
|
|
|
|
|
|
|
|
it('with the correct id, path, outputPath and template properties', () => {
|
|
|
|
const docs = [];
|
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs.pop()).toEqual(jasmine.objectContaining({
|
|
|
|
id: 'sitemap.xml',
|
|
|
|
path: 'sitemap.xml',
|
|
|
|
outputPath: '../sitemap.xml',
|
|
|
|
template: 'sitemap.template.xml'
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with an array of urls for each doc that has an outputPath', () => {
|
|
|
|
const docs = [
|
|
|
|
{ path: 'abc', outputPath: 'abc' },
|
|
|
|
{ path: 'cde' },
|
|
|
|
{ path: 'fgh', outputPath: 'fgh' },
|
|
|
|
];
|
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs.pop().urls).toEqual(['abc', 'fgh']);
|
|
|
|
});
|
2018-02-07 05:46:37 -05:00
|
|
|
|
|
|
|
it('ignoring blacklisted doc types', () => {
|
|
|
|
const docs = [
|
|
|
|
{ path: 'abc', outputPath: 'abc', docType: 'good' },
|
|
|
|
{ path: 'cde', outputPath: 'cde', docType: 'bad' },
|
|
|
|
{ path: 'fgh', outputPath: 'fgh', docType: 'good' },
|
|
|
|
];
|
2019-04-07 14:58:03 -04:00
|
|
|
processor.ignoredDocTypes = ['bad'];
|
2018-02-07 05:46:37 -05:00
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs.pop().urls).toEqual(['abc', 'fgh']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ignoring blacklisted paths', () => {
|
|
|
|
const docs = [
|
|
|
|
{ path: 'abc', outputPath: 'abc' },
|
|
|
|
{ path: 'cde', outputPath: 'cde' },
|
|
|
|
{ path: 'fgh', outputPath: 'fgh' },
|
|
|
|
];
|
2019-04-07 14:58:03 -04:00
|
|
|
processor.ignoredPaths = ['cde'];
|
2018-02-07 05:46:37 -05:00
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs.pop().urls).toEqual(['abc', 'fgh']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('mapping the home page\'s path to `/`', () => {
|
|
|
|
const docs = [
|
|
|
|
{ path: 'abc', outputPath: 'abc' },
|
|
|
|
{ path: 'index', outputPath: 'index.json' },
|
|
|
|
{ path: 'fgh', outputPath: 'fgh' },
|
|
|
|
];
|
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs.pop().urls).toEqual(['abc', '', 'fgh']);
|
|
|
|
});
|
2018-01-21 12:24:05 -05:00
|
|
|
});
|
|
|
|
});
|
2019-04-07 14:58:03 -04:00
|
|
|
});
|