cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [39/51] [abbrv] git commit: fixed failing tests recently introduced with Windows8 parser changes
Date Wed, 27 Nov 2013 22:27:38 GMT
fixed failing tests recently introduced with Windows8 parser changes


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/4700a64a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/4700a64a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/4700a64a

Branch: refs/heads/fireos
Commit: 4700a64a919c27f31034f38fd89ea904d216c5f4
Parents: b9badb3
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Wed Nov 27 11:53:14 2013 -0800
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Wed Nov 27 11:53:14 2013 -0800

----------------------------------------------------------------------
 spec/metadata/windows8_parser.spec.js | 66 ++++++++++++++----------------
 src/metadata/windows8_parser.js       | 14 ++++---
 2 files changed, 39 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4700a64a/spec/metadata/windows8_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/windows8_parser.spec.js b/spec/metadata/windows8_parser.spec.js
index 1187ac6..a9c77d7 100644
--- a/spec/metadata/windows8_parser.spec.js
+++ b/spec/metadata/windows8_parser.spec.js
@@ -44,14 +44,14 @@ describe('windows8 project parser', function() {
         cfg_parser = spyOn(util, 'config_parser');
     });
 
-    function wrapper(p, done, post) {
-        p.then(post, function(err) {
+    function wrapper(promise, done, post) {
+        promise.then(post, function(err) {
             expect(err).toBeUndefined();
         }).fin(done);
     }
 
-    function errorWrapper(p, done, post) {
-        p.then(function() {
+    function errorWrapper(promise, done, post) {
+        promise.then(function() {
             expect('this call').toBe('fail');
         }, post).fin(done);
     }
@@ -65,9 +65,9 @@ describe('windows8 project parser', function() {
         });
         it('should create an instance with path, manifest properties', function() {
             expect(function() {
-                var p = new platforms.windows8.parser(proj);
-                expect(p.windows8_proj_dir).toEqual(proj);
-                expect(p.manifest_path).toEqual(path.join(proj, 'package.appxmanifest'));
+                var parser = new platforms.windows8.parser(proj);
+                expect(parser.windows8_proj_dir).toEqual(proj);
+                expect(parser.manifest_path).toEqual(path.join(proj, 'package.appxmanifest'));
             }).not.toThrow();
         });
     });
@@ -100,10 +100,10 @@ describe('windows8 project parser', function() {
     });
 
     describe('instance', function() {
-        var p, cp, rm, is_cordova, write, read, mv, mkdir;
+        var parser, cp, rm, is_cordova, write, read, mv, mkdir;
         var windows8_proj = path.join(proj, 'platforms', 'windows8');
         beforeEach(function() {
-            p = new platforms.windows8.parser(windows8_proj);
+            parser = new platforms.windows8.parser(windows8_proj);
             cp = spyOn(shell, 'cp');
             rm = spyOn(shell, 'rm');
             mv = spyOn(shell, 'mv');
@@ -130,7 +130,7 @@ describe('windows8 project parser', function() {
                 };
                 root_obj = {
                     attrib:{
-                        package:'android_pkg'
+                        package:'windows8_pkg'
                     }
                 };
                 find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
@@ -154,7 +154,7 @@ describe('windows8 project parser', function() {
                 cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
                 cfg_pref_add = jasmine.createSpy('config_parser pref add');
                 cfg_content = jasmine.createSpy('config_parser content');
-                p.config = {
+                parser.config = {
                     access:{
                         remove:cfg_access_rm,
                         get:function(){},
@@ -171,44 +171,40 @@ describe('windows8 project parser', function() {
             });
 
             it('should write out the app name to package.appxmanifest', function() {
-                //following line outputs json
-                p.update_from_config(cfg);
-                expect(find_obj.attrib.Id).toEqual('testname');
+                parser.update_from_config(cfg);
+                expect(find_obj.attrib.Name).toEqual(cfg.packageName());
+                expect(find_obj.attrib.DisplayName).toEqual(cfg.name());
             });
 
-            // This test removed (jm) does not seem to be valid in winjs land.
-            // it('should write out the app id to jsproj file', function() {
-            //     p.update_from_config(cfg);
-            //     expect(find_obj.text).toContain('testpkg');
-            // });
-
             it('should write out the app version to package.appxmanifest', function() {
-                p.update_from_config(cfg);
+                parser.update_from_config(cfg);
                 expect(find_obj.attrib.Version).toEqual('one point oh');
             });
-           it('should update the content element (start page)', function() {
-                p.update_from_config(cfg);
+
+            it('should update the content element (start page)', function() {
+                parser.update_from_config(cfg);
                 expect(cfg_content).toHaveBeenCalledWith('index.html');
             });
 
         });
+
         describe('www_dir method', function() {
             it('should return www', function() {
-                expect(p.www_dir()).toEqual(path.join(windows8_proj, 'www'));
+                expect(parser.www_dir()).toEqual(path.join(windows8_proj, 'www'));
             });
         });
         describe('staging_dir method', function() {
             it('should return .staging/www', function() {
-                expect(p.staging_dir()).toEqual(path.join(windows8_proj, '.staging', 'www'));
+                expect(parser.staging_dir()).toEqual(path.join(windows8_proj, '.staging',
'www'));
             });
         });
         describe('update_www method', function() {
             var update_jsproj;
             beforeEach(function() {
-                update_jsproj = spyOn(p, 'update_jsproj');
+                update_jsproj = spyOn(parser, 'update_jsproj');
             });
             it('should rm project-level www and cp in platform agnostic www', function()
{
-                p.update_www(path.join('lib','dir'));
+                parser.update_www(path.join('lib','dir'));
                 expect(rm).toHaveBeenCalled();
                 expect(cp).toHaveBeenCalled();
             });
@@ -216,38 +212,38 @@ describe('windows8 project parser', function() {
         describe('update_staging method', function() {
             it('should do nothing if staging dir does not exist', function() {
                 exists.andReturn(false);
-                p.update_staging();
+                parser.update_staging();
                 expect(cp).not.toHaveBeenCalled();
             });
             it('should copy the staging dir into www if staging dir exists', function() {
-                p.update_staging();
+                parser.update_staging();
                 expect(cp).toHaveBeenCalled();
             });
         });
         describe('update_project method', function() {
             var config, www, overrides, staging, svn;
             beforeEach(function() {
-                config = spyOn(p, 'update_from_config');
-                staging = spyOn(p, 'update_staging');
+                config = spyOn(parser, 'update_from_config');
+                staging = spyOn(parser, 'update_staging');
                 svn = spyOn(util, 'deleteSvnFolders');
             });
             it('should call update_from_config', function() {
-                p.update_project();
+                parser.update_project();
                 expect(config).toHaveBeenCalled();
             });
             it('should throw if update_from_config throws', function(done) {
                 var err = new Error('uh oh!');
                 config.andCallFake(function() { throw err; });
-                errorWrapper(p.update_project({}), done, function(err) {
+                errorWrapper(parser.update_project({}), done, function(err) {
                     expect(err).toEqual(err);
                 });
             });
             it('should call update_staging', function() {
-                p.update_project();
+                parser.update_project();
                 expect(staging).toHaveBeenCalled();
             });
             it('should call deleteSvnFolders', function() {
-                p.update_project();
+                parser.update_project();
                 expect(svn).toHaveBeenCalled();
             });
         });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4700a64a/src/metadata/windows8_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/windows8_parser.js b/src/metadata/windows8_parser.js
index bc41d34..f8e0776 100644
--- a/src/metadata/windows8_parser.js
+++ b/src/metadata/windows8_parser.js
@@ -131,7 +131,7 @@ module.exports.prototype = {
 
         // Update properties
         var properties = manifest.find('.//Properties');
-        if (properties) {
+        if (properties && properties.find) {
             var displayNameElement = properties.find('.//DisplayName');
             if (displayNameElement && displayNameElement.text != name) {
                 displayNameElement.text = name;
@@ -146,7 +146,7 @@ module.exports.prototype = {
         // sort Capability elements as per CB-5350 Windows8 build fails due to invalid 'Capabilities'
definition
         // to sort elements we remove them and then add again in the appropriate order
         var capabilitiesRoot = manifest.find('.//Capabilities'),
-            capabilities = capabilitiesRoot._children;
+            capabilities = capabilitiesRoot._children || [];
 
         capabilities.forEach(function(elem){
             capabilitiesRoot.remove(0, elem);
@@ -288,7 +288,7 @@ module.exports.prototype = {
         }
         // overrides (merges) are handled in update_www()
         this.update_staging();
-        this.add_bom();
+        //this.add_bom();
 
         util.deleteSvnFolders(this.www_dir());
         return Q();
@@ -296,9 +296,11 @@ module.exports.prototype = {
 
     // Adjust version number as per CB-5337 Windows8 build fails due to invalid app version
       
     fixConfigVersion: function (version) {
-        var numVersionComponents = version.match(/\./g).length + 1;
-        while (numVersionComponents++ < 4) {
-            version += '.0';
+        if(version && version.match(/\.d/g)) {
+            var numVersionComponents = version.match(/\.d/g).length + 1;
+            while (numVersionComponents++ < 4) {
+                version += '.0';
+            }
         }
         return version;
     },


Mime
View raw message