build(aio): improve error message for ignored example files (#19265)

Addresses https://github.com/angular/angular/pull/18707#issuecomment-330396771

PR Close #19265
This commit is contained in:
Peter Bacon Darwin
2017-09-19 10:15:39 +01:00
committed by Igor Minar
parent 988b9f8378
commit 381e680758
5 changed files with 209 additions and 149 deletions

View File

@ -11,6 +11,7 @@ describe('getExampleRegion', () => {
collectExamples = injector.get('collectExamples');
exampleMap = injector.get('exampleMap');
collectExamples.exampleFolders = ['examples'];
collectExamples.registerIgnoredExamples(['filtered/path'], 'some/gitignore');
exampleMap['examples'] = {
'test/url': { regions: {
'': { renderedContent: 'whole file' },
@ -27,12 +28,19 @@ describe('getExampleRegion', () => {
expect(getExampleRegion({}, 'test/url', 'region-1')).toEqual('region 1 contents');
});
it('should throw an error if an example doesn\'t exist', function() {
expect(function() {
it('should throw an error if an example doesn\'t exist', () => {
expect(() => {
getExampleRegion({}, 'missing/file', 'region-1');
}).toThrowError();
expect(function() {
}).toThrowError('Missing example file... relativePath: "missing/file". - doc\nExample files can be found in the following relative paths: "examples"');
expect(() => {
getExampleRegion({}, 'test/url', 'missing-region');
}).toThrowError();
}).toThrowError('Missing example region... relativePath: "test/url", region: "missing-region". - doc\nRegions available are: "", "region-1"');
});
it('should throw an error if an example has been filtered out', () => {
expect(() => {
getExampleRegion({}, 'filtered/path', 'any-region');
}).toThrowError('Ignored example file... relativePath: "filtered/path" - doc\n' +
'This example file exists but has been ignored by a rule, in "some/gitignore".');
});
});