From 1282da1b14e117aa6bc1407300de33edc40aa2a0 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Wed, 22 Feb 2017 18:12:34 +0000 Subject: [PATCH] feat(aio): support unannotated JSON example files --- aio/transforms/examples-package/services/region-parser.js | 4 ++++ .../examples-package/services/region-parser.spec.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/aio/transforms/examples-package/services/region-parser.js b/aio/transforms/examples-package/services/region-parser.js index 90efabb854..a664325eef 100644 --- a/aio/transforms/examples-package/services/region-parser.js +++ b/aio/transforms/examples-package/services/region-parser.js @@ -20,6 +20,7 @@ regionParserImpl.regionMatchers = { css: blockC, yaml: inlineHash, jade: inlineCOnly, + json: inlineC, 'json.annotated': inlineC }; @@ -97,6 +98,9 @@ function regionParserImpl(contents, fileType) { // this line contained an annotation so let's filter it out return false; }); + if (!regionMap['']) { + regionMap[''] = {lines}; + } return { contents: lines.join('\n'), regions: mapObject(regionMap, (regionName, region) => region.lines.join('\n')) diff --git a/aio/transforms/examples-package/services/region-parser.spec.js b/aio/transforms/examples-package/services/region-parser.spec.js index 56141e7bef..3c81a9ab25 100644 --- a/aio/transforms/examples-package/services/region-parser.spec.js +++ b/aio/transforms/examples-package/services/region-parser.spec.js @@ -25,7 +25,7 @@ describe('regionParser service', () => { it('should return just the contents if there is a region-matcher but no regions', () => { const output = regionParser('some contents', 'test-type'); - expect(output).toEqual({contents: 'some contents', regions: {}}); + expect(output).toEqual({contents: 'some contents', regions: { '': 'some contents' }}); }); it('should remove start region annotations from the contents', () => {