UNPKG

@nlighten/json-transform-core

Version:

Core types and utilities for handling JSON transformers

143 lines (142 loc) 4.48 kB
[ { "name": "inline - simple", "given": { "input": { "root": "" }, "definition": "$$xml:$" }, "expect": { "equal": "<root/>", "format": "xml" } }, { "name": "inline - 2 elements", "given": { "input": { "root": "", "root_b": "" }, "definition": "$$xml:$" }, "expect": { "equal": "<root/><root_b/>", "format": "xml" } }, { "name": "inline - 2 elements inside a container", "given": { "input": { "root": "", "root_b": "" }, "definition": "$$xml(container):$" }, "expect": { "equal": "<container><root/><root_b/></container>", "format": "xml" } }, { "name": "inline - indent", "given": { "input": { "root": "", "root_b": "" }, "definition": "$$xml(container,,true):$" }, "expect": { "equal": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><container>\n <root/>\n <root_b/>\n</container>\n", "format": "xml" } }, { "name": "object - simple", "given": { "input": { "root": "" }, "definition": { "$$xml": "$", "root": "container" } }, "expect": { "equal": "<container><root/></container>", "format": "xml" } }, { "name": "object - array", "given": { "input": null, "definition": { "$$xml": { "hello": { "hi": ["", ""], "to": "world" } } } }, "expect": { "equal": "<hello><hi/><hi/><to>world</to></hello>", "format": "xml" } }, { "name": "object - xslt", "skip": ["javascript"], "given": { "input": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <xsl:stylesheet version=\"1.0\"\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n \n <xsl:template match=\"/container\">\n <my_record>\n <first><xsl:value-of select=\"a\" /></first>\n <second><xsl:value-of select=\"b\" /></second>\n </my_record>\n </xsl:template>\n \n </xsl:stylesheet>", "inputFormat": "xml", "definition": { "$$xml": { "a": "AAA", "b": "BBB" }, "root": "container", "xslt": "$" } }, "expect": { "equal": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><my_record><first>AAA</first><second>BBB</second></my_record>", "format": "xml" } }, { "name": "object - xslt of pretty print", "skip": ["javascript"], "given": { "input": "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:output method=\"xml\" indent=\"yes\"/><xsl:strip-space elements=\"*\"/><xsl:template match=\"/\"><xsl:copy-of select=\".\"/></xsl:template></xsl:stylesheet>", "inputFormat": "xml", "definition": { "$$xml": { "tag1": { "value": "lorem" }, "tag2": { "items": [ { "id": 1 }, { "id": 2 } ] } }, "root": "root", "xslt": "$" } }, "expect": { "equal": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <tag1>\n <value>lorem</value>\n </tag1>\n <tag2>\n <items>\n <id>1</id>\n </items>\n <items>\n <id>2</id>\n </items>\n </tag2>\n</root>\n", "format": "xml" } } ]