cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject git commit: CB-5106:[win8] fixed tests for windows 8
Date Sat, 19 Oct 2013 23:07:28 GMT
Updated Branches:
  refs/heads/master 7c74aa5a1 -> 595a473ae


CB-5106:[win8] fixed tests for windows 8


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

Branch: refs/heads/master
Commit: 595a473aeaa41796b7b7d8386ab1fea8aa4be498
Parents: 7c74aa5
Author: Steven Gill <stevengill97@gmail.com>
Authored: Sat Oct 19 16:06:23 2013 -0700
Committer: Steven Gill <stevengill97@gmail.com>
Committed: Sat Oct 19 16:06:23 2013 -0700

----------------------------------------------------------------------
 spec/metadata/firefoxos_parser.spec.js |  4 +--
 spec/metadata/windows8_parser.spec.js  | 38 +++++++++++++++++++----------
 src/metadata/windows8_parser.js        |  2 +-
 3 files changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/595a473a/spec/metadata/firefoxos_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/firefoxos_parser.spec.js b/spec/metadata/firefoxos_parser.spec.js
index e6bc786..5d20579 100644
--- a/spec/metadata/firefoxos_parser.spec.js
+++ b/spec/metadata/firefoxos_parser.spec.js
@@ -89,10 +89,10 @@ describe('firefoxos project parser', function() {
                 });
             });
 
-            it('should write manifest.webapp', function() {
+          /*  it('should write manifest.webapp', function() {
                 //p.update_from_config(cfg);
                 //expect(write.mostRecentCall.args[0]).toEqual('manifest.webapp');
-            });
+            });*/
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/595a473a/spec/metadata/windows8_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/windows8_parser.spec.js b/spec/metadata/windows8_parser.spec.js
index 7e2cb87..9f1b138 100644
--- a/spec/metadata/windows8_parser.spec.js
+++ b/spec/metadata/windows8_parser.spec.js
@@ -21,6 +21,8 @@ var platforms = require('../../platforms'),
     util = require('../../src/util'),
     path = require('path'),
     shell = require('shelljs'),
+    child_process = require('child_process'),
+    Q = require('q'),
     fs = require('fs'),
     ET = require('elementtree'),
     config = require('../../src/config'),
@@ -33,13 +35,26 @@ describe('windows8 project parser', function() {
     var exists, exec, custom, readdir, cfg_parser;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
-        exec = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
-            cb(0, '');
+        exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) {
+            if (!cb) cb = opts;
+            cb(null, '', '');
         });
         custom = spyOn(config, 'has_custom_path').andReturn(false);
         readdir = spyOn(fs, 'readdirSync').andReturn(['test.jsproj']);
         cfg_parser = spyOn(util, 'config_parser');
     });
+    
+    function wrapper(p, done, post) {
+        p.then(post, function(err) {
+            expect(err).toBeUndefined();
+        }).fin(done);
+    }
+
+    function errorWrapper(p, done, post) {
+        p.then(function() {
+            expect('this call').toBe('fail');
+        }, post).fin(done);
+    }
 
     describe('constructions', function() {
         it('should throw if provided directory does not contain a jsproj file', function()
{
@@ -60,30 +75,27 @@ describe('windows8 project parser', function() {
     describe('check_requirements', function() {
         it('should fire a callback if there is an error during shelling out', function(done)
{
             exec.andCallFake(function(cmd, opts, cb) {
-                cb(50, 'there was an errorz!');
+                if (!cb) cb = opts;
+                cb(50, 'there was an errorz!', '');
             });
-            platforms.windows8.parser.check_requirements(proj, function(err) {
+            errorWrapper(platforms.windows8.parser.check_requirements(proj), done, function(err)
{
                 expect(err).toContain('there was an errorz!');
-                done();
             });
         });
         it('should check by calling check_reqs on the stock lib path if no custom path is
defined', function(done) {
-            platforms.windows8.parser.check_requirements(proj, function(err) {
-                expect(err).toEqual(false);
+            wrapper(platforms.windows8.parser.check_requirements(proj), done, function()
{
                 expect(exec.mostRecentCall.args[0]).toContain(util.libDirectory);
                 expect(exec.mostRecentCall.args[0]).toMatch(/check_reqs"$/);
-                done();
             });
         });
         it('should check by calling check_reqs on a custom path if it is so defined', function(done)
{
             var custom_path = path.join('some','custom','path','to','windows8','lib');
             custom.andReturn(custom_path);
-            platforms.windows8.parser.check_requirements(proj, function(err) {
-                expect(err).toEqual(false);
+            wrapper(platforms.windows8.parser.check_requirements(proj),done, function() {
                 expect(exec.mostRecentCall.args[0]).toContain(custom_path);
                 expect(exec.mostRecentCall.args[0]).toMatch(/check_reqs"$/);
-                done();
             });
+            done();
         });
     });
 
@@ -158,6 +170,7 @@ 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');
             });
@@ -237,9 +250,8 @@ describe('windows8 project parser', function() {
             it('should throw if update_from_config throws', function(done) {
                 var err = new Error('uh oh!');
                 config.andCallFake(function() { throw err; });
-                p.update_project({}, function(err) {
+                errorWrapper(p.update_project({}), done, function(err) {
                     expect(err).toEqual(err);
-                    done();
                 });
             });
             it('should call update_www', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/595a473a/src/metadata/windows8_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/windows8_parser.js b/src/metadata/windows8_parser.js
index b438510..120faef 100644
--- a/src/metadata/windows8_parser.js
+++ b/src/metadata/windows8_parser.js
@@ -56,6 +56,7 @@ module.exports.check_requirements = function(project_root) {
     var command = '"' + path.join(lib_path, 'bin', 'check_reqs') + '"';
     events.emit('verbose', 'Running "' + command + '" (output to follow)');
     var d = Q.defer();
+    
     child_process.exec(command, function(err, output, stderr) {
         events.emit('verbose', output);
         if (err) {
@@ -100,7 +101,6 @@ module.exports.prototype = {
             }
 
             var visualElems = manifest.find('.//VisualElements');
-            console.log(visualElems);
 
             if(visualElems) {
                 var displayName = visualElems['attrib']['DisplayName'];


Mime
View raw message