From e376f83b35eec0916aaa9ba1894d8e8d9336e6a6 Mon Sep 17 00:00:00 2001 From: Brian Mulhall Date: Thu, 20 Feb 2020 11:44:43 -0600 Subject: [PATCH] updated the tests to help identify which function (each used function has a separate test case now) has failed in the event that a library update causes the api's behavior to change version to version from what we have come to expect --- packages/xmlbuilder/xmlbuilder_tests.js | 96 ++++++++++++++++--------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/packages/xmlbuilder/xmlbuilder_tests.js b/packages/xmlbuilder/xmlbuilder_tests.js index a3b894fbab..74c8532945 100644 --- a/packages/xmlbuilder/xmlbuilder_tests.js +++ b/packages/xmlbuilder/xmlbuilder_tests.js @@ -1,40 +1,39 @@ -const expectedResult = `XmlBuilderTestThis is a Meteor test caseMeteor Developer`; - -const accessRules = { - 'tel:*': { type: 'intent' }, - 'geo:*': { type: 'intent' }, - 'mailto:*': { type: 'intent' }, - 'sms:*': { type: 'intent' }, - 'market:*': { type: 'intent' }, - 'itms:*': { type: 'intent' }, - 'itms-apps:*': { type: 'intent' }, - 'http://localhost': { type: 'navigation' } -}; - -const metadata = { - id: 'com.meteor.xmlbuilder_test', - version: '0.0.1', - author: 'Meteor Developer', - contentUrl: `http://localhost:3000/` -}; - -const additionalConfiguration = { - global: { - 'webviewbounce': false, - 'DisallowOverscroll': true - }, - platform: { - ios: {}, - android: {} - } -}; - -const custom = [``]; - // this test case mimics about 80 precent of the code used to build the // config.xml file from the following file (meteor/tools/cordova/builder.js) // and it exercies all the funcitons used from the xmlbuilder2 api Tinytest.add("xmlbuilder - config.xml file generation", function (test) { + const expectedResult = `XmlBuilderTestThis is a Meteor test caseMeteor Developer`; + + const accessRules = { + 'tel:*': { type: 'intent' }, + 'geo:*': { type: 'intent' }, + 'mailto:*': { type: 'intent' }, + 'sms:*': { type: 'intent' }, + 'market:*': { type: 'intent' }, + 'itms:*': { type: 'intent' }, + 'itms-apps:*': { type: 'intent' }, + 'http://localhost': { type: 'navigation' } + }; + + const metadata = { + id: 'com.meteor.xmlbuilder_test', + version: '0.0.1', + author: 'Meteor Developer', + contentUrl: `http://localhost:3000/` + }; + + const additionalConfiguration = { + global: { + 'webviewbounce': false, + 'DisallowOverscroll': true + }, + platform: { + ios: {}, + android: {} + } + }; + + const custom = [``]; let config = XmlBuilder.create({ version: '1.0' }).ele('widget'); // Set the root attributes @@ -107,5 +106,36 @@ Tinytest.add("xmlbuilder - config.xml file generation", function (test) { test.equal(formattedXmlConfig, expectedResult); }); +Tinytest.add("xmlbuilder - create() funciton", function (test) { + const expectedResult = ''; + + let widgetNode = XmlBuilder.create({ version: '1.0' }).ele('widget'); + let formattedXmlConfig = widgetNode.end(); + test.equal(formattedXmlConfig, expectedResult); + + widgetNode = XmlBuilder.create().ele('widget'); + formattedXmlConfig = widgetNode.end(); + test.equal(formattedXmlConfig, expectedResult); + +}); + +Tinytest.add("xmlbuilder - att() function", function (test) { + const expectedResult = ''; + + let config = XmlBuilder.create().ele('widget'); + config.att({ key: 'test' }); + let formattedXmlConfig = config.end(); + test.equal(formattedXmlConfig, expectedResult); +}); + +Tinytest.add("xmlbuilder - ele() function", function (test) { + let expectedResult = 'XmlBuilderTest'; + let config = XmlBuilder.create().ele('widget'); + config.ele('name').txt('XmlBuilderTest'); + + const formattedXmlConfig = config.end(); + test.equal(formattedXmlConfig, expectedResult); +}); +