Fix xml-helpers issue by adding close tag
authorknaito <knaito@asial.co.jp>
Fri, 31 Aug 2018 04:03:07 +0000 (13:03 +0900)
committerDarryl Pogue <dvpdiner2@gmail.com>
Fri, 31 Aug 2018 05:11:41 +0000 (22:11 -0700)
spec/fixtures/test-config0.xml [new file with mode: 0644]
spec/util/xml-helpers.spec.js
src/util/xml-helpers.js

diff --git a/spec/fixtures/test-config0.xml b/spec/fixtures/test-config0.xml
new file mode 100644 (file)
index 0000000..bfdbb5a
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding='utf-8'?>
+<widget android-packageName="io.cordova.hellocordova.android" id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+    <name>Hello Cordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <access origin="*" />
+</widget>
index f4d5fbc..e117139 100644 (file)
@@ -209,6 +209,12 @@ describe('xml-helpers', function () {
             xml_helpers.graftXML(config_xml, children, '/*');
             expect(config_xml.findall('access').length).toEqual(3);
         });
+        it('Test 020-1 : should create parent', function () {
+            var config_xml0 = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/test-config0.xml'));
+            var children = plugin_xml.find('platform[@name="ios"]/config-file').getchildren();
+            xml_helpers.graftXML(config_xml0, children, '/widget/plugins');
+            expect(config_xml0.find('plugins').getchildren().length).toEqual(1);
+        });
     });
 
     describe('graftXMLMerge', function () {
index acb610b..df51583 100644 (file)
@@ -61,7 +61,7 @@ module.exports = {
         if (!parent) {
             // Try to create the parent recursively if necessary
             try {
-                var parentToCreate = et.XML('<' + path.basename(selector) + '>');
+                var parentToCreate = et.XML('<' + path.basename(selector) + '/>');
                 var parentSelector = path.dirname(selector);
 
                 this.graftXML(doc, [parentToCreate], parentSelector);