diff --git a/__tests__/data/pretty1.html b/__tests__/data/pretty1.html
index c717a5d..ac63b9f 100644
--- a/__tests__/data/pretty1.html
+++ b/__tests__/data/pretty1.html
@@ -1 +1 @@
-
{
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "object",
"title": "My Web Site",
"properties": {
"site_info": {
"type": "object",
"title": "Site Info",
"properties": {
"favicon": {
"type": "string",
"title": "Favicon"
},
"logo": {
"type": "string",
"title": "Logo"
},
"copyright": {
"type": "string",
"title": "Copyright"
}
}
},
"nav": {
"type": "object",
"title": "Nav",
"properties": {
"header": {
"type": "array",
"title": "Header",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"title": "Label"
},
"url": {
"type": "string",
"title": "Url"
}
}
}
},
"footer": {
"type": "array",
"title": "Footer",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"title": "Label"
},
"url": {
"type": "string",
"title": "Url"
},
"target": {
"type": "string",
"title": "Target"
}
}
}
}
}
},
"pages": {
"type": "array",
"title": "Pages",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"title": "Key"
},
"heading": {
"type": "string",
"title": "Heading"
},
"body": {
"type": "string",
"title": "Body",
"format": "markdown"
},
"search_enabled": {
"type": "boolean",
"title": "Search Enabled"
},
"tags": {
"type": "array",
"title": "Tags",
"description": "An array of tags",
"items": {
"type": "string"
}
},
"title": {
"type": "string",
"title": "Title",
"description": "The SEO title of the page, for web crawlers"
},
"description": {
"type": "string",
"title": "Description",
"format": "textarea",
"className": "short",
"description": "The SEO description of the page, for web crawlers"
}
}
}
},
"messages": {
"type": "object",
"title": "Messages",
"properties": {
"errors": {
"type": "object",
"title": "Errors",
"patternProperties": {
".+": {
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Title"
},
"message": {
"type": "string",
"title": "Message"
}
},
"keyTitle": "Identifier"
}
}
},
"tooltips": {
"type": "object",
"title": "Tooltips",
"patternProperties": {
".+": {
"type": "string",
"keyTitle": "Identifier",
"valueTitle": "Message"
}
}
}
}
}
}
}
\ No newline at end of file
+
{
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "object",
"title": "My Web Site",
"properties": {
"site_info": {
"type": "object",
"title": "Site Info",
"properties": {
"favicon": {
"type": "string",
"title": "Favicon"
},
"logo": {
"type": "string",
"title": "Logo"
},
"copyright": {
"type": "string",
"title": "Copyright"
}
}
},
"nav": {
"type": "object",
"title": "Nav",
"properties": {
"header": {
"type": "array",
"title": "Header",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"title": "Label"
},
"url": {
"type": "string",
"title": "Url"
}
}
}
},
"footer": {
"type": "array",
"title": "Footer",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"title": "Label"
},
"url": {
"type": "string",
"title": "Url"
},
"target": {
"type": "string",
"title": "Target"
}
}
}
}
}
},
"pages": {
"type": "array",
"title": "Pages",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"title": "Key"
},
"heading": {
"type": "string",
"title": "Heading"
},
"body": {
"type": "string",
"title": "Body",
"format": "markdown"
},
"search_enabled": {
"type": "boolean",
"title": "Search Enabled"
},
"tags": {
"type": "array",
"title": "Tags",
"description": "An array of tags",
"items": {
"type": "string"
}
},
"title": {
"type": "string",
"title": "Title",
"description": "The SEO title of the page, for web crawlers"
},
"description": {
"type": "string",
"title": "Description",
"format": "textarea",
"className": "short",
"description": "The SEO description of the page, for web crawlers"
}
}
}
},
"messages": {
"type": "object",
"title": "Messages",
"properties": {
"errors": {
"type": "object",
"title": "Errors",
"patternProperties": {
".+": {
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Title"
},
"message": {
"type": "string",
"title": "Message"
}
},
"keyTitle": "Identifier"
}
}
},
"tooltips": {
"type": "object",
"title": "Tooltips",
"patternProperties": {
".+": {
"type": "string",
"keyTitle": "Identifier",
"valueTitle": "Message"
}
}
}
}
}
}
}
diff --git a/__tests__/data/pretty2.html b/__tests__/data/pretty2.html
index 4871600..361ac11 100644
--- a/__tests__/data/pretty2.html
+++ b/__tests__/data/pretty2.html
@@ -1 +1 @@
-
{
"site_info": {
"copyright": "",
"favicon": "favicon.ico"
},
"nav": {
"footer": [
{
"label": "About",
"url": "/about"
},
{
"label": "Facebook",
"url": "www.facebook.com/mywebsite",
"target": "_blank"
},
{
"label": "Twitter",
"url": "https://twitter/mywebsite",
"target": "_blank"
}
],
"header": [
{
"label": "Home",
"url": "/home"
},
{
"label": "Product",
"url": "/product"
},
{
"label": "Blog",
"url": "/blog"
}
]
},
"pages": [
{
"key": "A Page",
"body": "",
"search_enabled": true,
"heading": "hello",
"tags": [
"foo",
"bar",
"hux"
]
},
{
"key": "Another Page"
}
],
"messages": {
"errors": {
"internalError": {
"title": "Internal Error",
"message": "An internal error occurred"
},
"connectionError": {
"title": "Network Error",
"message": "There seem to be network issues"
}
},
"tooltips": {
"welcome": "Welcome to my web site",
"sendEmail": "click to send an email"
}
}
}
\ No newline at end of file
+
{
"site_info": {
"copyright": "",
"favicon": "favicon.ico"
},
"nav": {
"footer": [
{
"label": "About",
"url": "/about"
},
{
"label": "Facebook",
"url": "www.facebook.com/mywebsite",
"target": "_blank"
},
{
"label": "Twitter",
"url": "https://twitter/mywebsite",
"target": "_blank"
}
],
"header": [
{
"label": "Home",
"url": "/home"
},
{
"label": "Product",
"url": "/product"
},
{
"label": "Blog",
"url": "/blog"
}
]
},
"pages": [
{
"key": "A Page",
"body": "",
"search_enabled": true,
"heading": "hello",
"tags": [
"foo",
"bar",
"hux"
]
},
{
"key": "Another Page"
}
],
"messages": {
"errors": {
"internalError": {
"title": "Internal Error",
"message": "An internal error occurred"
},
"connectionError": {
"title": "Network Error",
"message": "There seem to be network issues"
}
},
"tooltips": {
"welcome": "Welcome to my web site",
"sendEmail": "click to send an email"
}
}
}
diff --git a/__tests__/prettyPrint.spec.ts b/__tests__/prettyPrint.spec.ts
index eb2bd02..53a5b3d 100755
--- a/__tests__/prettyPrint.spec.ts
+++ b/__tests__/prettyPrint.spec.ts
@@ -15,7 +15,8 @@ const testPrettyPrint = (jsonFile: string, expected: string, selection: string)
'.json-string{ color: green } .json-boolean{ color: blue } ' +
'.json-selected { background-color: #ddd }';
const all = `${styles}
${html}`;
- expect(all).toBe(results[1].toString());
+ var expectedTrimmed = results[1].toString().replace(/^\s+|\s+$/g, '');
+ expect(all).toBe(expectedTrimmed);
});
});
};
@@ -30,25 +31,25 @@ test('undefinedOrNull', () => {
test('simple', () => {
const object = { foo: { bar: 'hux' } };
- expect(prettyPrint(object)).toBe('{
"foo": {
"bar": "hux"
}
}
');
- expect(prettyPrint(object, object.foo)).toBe('{
"foo": {
"bar": "hux"
}
}
');
- expect(prettyPrint(object, object)).toBe('{
"foo": {
"bar": "hux"
}
}
');
+ expect(prettyPrint(object)).toBe('{
"foo": {
"bar": "hux"
}
}
');
+ expect(prettyPrint(object, object.foo)).toBe('{
"foo": {
"bar": "hux"
}
}
');
+ expect(prettyPrint(object, object)).toBe('{
"foo": {
"bar": "hux"
}
}
');
});
test('array', () => {
const json = [ 'foo', 'bar' ];
- expect(prettyPrint(json)).toBe('[
"foo",
"bar"
]
');
+ expect(prettyPrint(json)).toBe('[
"foo",
"bar"
]
');
});
test('arrayWithObject', () => {
const json = [ 'foo', { bar : 'hux' } ];
- expect(prettyPrint(json)).toBe('[
"foo",
{
"bar": "hux"
}
]
');
- expect(prettyPrint(json,