From aa9a2a3ecf27d2119ae3a074480313495f0441d0 Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:01:46 -0700 Subject: [PATCH] Adding unit test for https://github.com/DesignLiquido/xslt-processor/issues/110. --- tests/xslt/apply-template.test.ts | 66 +++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/tests/xslt/apply-template.test.ts b/tests/xslt/apply-template.test.ts index 20cfe72..2e49222 100644 --- a/tests/xslt/apply-template.test.ts +++ b/tests/xslt/apply-template.test.ts @@ -40,26 +40,66 @@ describe('xsl:apply-template', () => { }); it.skip('XSLT template with text on both sides', async () => { - const xmlString = ` - This text lost - `; + const xmlString = ` + This text lost + `; - const xsltString = ` + const xsltString = ` XY `; - const expectedOutString = `Xtest1Y`; + const expectedOutString = `Xtest1Y`; + + const xsltClass = new Xslt(); + const xmlParser = new XmlParser(); + const xml = xmlParser.xmlParse(xmlString); + const xslt = xmlParser.xmlParse(xsltString); + + const outXmlString = await xsltClass.xsltProcess(xml, xslt); + + assert.equal(outXmlString, expectedOutString); + }); + + it.skip('https://github.com/DesignLiquido/xslt-processor/issues/110', async () => { + const xmlString = ` + +
+ My Article + + Mr. Foo + Mr. Bar + + This is my article text. +
`; + + const xsltString = ` + + + + + + Article - + Authors: + + + + - + + + `; + + const expectedOutString = `Article - My Article\nAuthors:\n- Mr. Foo\n- Mr. Bar`; - const xsltClass = new Xslt(); - const xmlParser = new XmlParser(); - const xml = xmlParser.xmlParse(xmlString); - const xslt = xmlParser.xmlParse(xsltString); + const xsltClass = new Xslt(); + const xmlParser = new XmlParser(); + const xml = xmlParser.xmlParse(xmlString); + const xslt = xmlParser.xmlParse(xsltString); - const outXmlString = await xsltClass.xsltProcess(xml, xslt); + const outXmlString = await xsltClass.xsltProcess(xml, xslt); - assert.equal(outXmlString, expectedOutString); - }); -}); \ No newline at end of file + assert.equal(outXmlString, expectedOutString); + }); +});