build specs for bb10 support

Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/8f41b0ca
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/8f41b0ca
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/8f41b0ca

Branch: refs/heads/cordova-client
Commit: 8f41b0ca7348372e1352da72c1c963b797eb3b59
Parents: 1c0d98f
Author: Fil Maj <maj....@gmail.com>
Authored: Wed Sep 26 14:15:37 2012 -0700
Committer: Fil Maj <maj....@gmail.com>
Committed: Wed Sep 26 14:15:37 2012 -0700

----------------------------------------------------------------------
 spec/build.spec.js |   54 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/8f41b0ca/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
index 98e25bb..5a8b90b 100644
--- a/spec/build.spec.js
+++ b/spec/build.spec.js
@@ -87,7 +87,7 @@ describe('build command', function() {
                 expect(s.mostRecentCall.args[0].match(/android\/cordova\/debug 
> \/dev\/null$/)).not.toBeNull();
             });
         });
-        it('should shelll out to debug command on iOS', function() {
+        it('should shell out to debug command on iOS', function() {
             var buildcb = jasmine.createSpy();
             var cb = jasmine.createSpy();
             var s;
@@ -106,6 +106,28 @@ describe('build command', function() {
                 expect(s.mostRecentCall.args[0].match(/ios\/cordova\/debug > 
\/dev\/null$/)).not.toBeNull();
             });
         });
+        it('should shell out to ant command on blackberry-10', function() {
+            var buildcb = jasmine.createSpy();
+            var cb = jasmine.createSpy();
+            var s, t;
+
+            runs(function() {
+                cordova.platform('add', 'blackberry-10', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, 'platform add 
blackberry callback');
+            runs(function() {
+                s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
+                t = spyOn(require('prompt'), 'get').andReturn(true);
+                cordova.build(buildcb);
+                // Fake prompt invoking its callback
+                t.mostRecentCall.args[1](null, {});
+            });
+            waitsFor(function() { return buildcb.wasCalled; }, 'build call', 
20000);
+            runs(function() {
+                expect(s).toHaveBeenCalled();
+                expect(s.mostRecentCall.args[0].match(/ant -f .*build\.xml qnx 
load-device/)).not.toBeNull();
+            });
+        });
     });
 
     describe('before each run it should interpolate config.xml app metadata', 
function() {
@@ -174,5 +196,35 @@ describe('build command', function() {
             });
             it('should interpolate package name');
         });
+        describe('into BB10 builds', function() {
+            it('should interpolate app name', function() {
+                var buildcb = jasmine.createSpy();
+                var cb = jasmine.createSpy();
+                var newName = "fuck it dude. let's go bowling.", s, t;
+
+                runs(function() {
+                    cordova.platform('add', 'blackberry-10', cb);
+                });
+                waitsFor(function() { return cb.wasCalled; }, 'platform add 
blackberry callback');
+
+                runs(function() {
+                    // intercept call to ./cordova/debug to speed things up
+                    s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
+                    cfg = new config_parser(path.join(tempDir, 'www', 
'config.xml'));
+                    cfg.name(newName); // set a new name in the config.xml
+                    t = spyOn(require('prompt'), 'get').andReturn(true);
+                    cordova.build(buildcb);
+                    t.mostRecentCall.args[1](null, {});
+                });
+                waitsFor(function() { return buildcb.wasCalled; }, 'build 
call', 20000);
+
+                runs(function() {
+                    var bbcfg = path.join(tempDir, 'platforms', 
'blackberry-10', 'www', 'config.xml');
+                    var doc = new et.ElementTree(et.XML(fs.readFileSync(bbcfg, 
'utf-8')));
+                    expect(doc.find('name').text).toBe(newName);
+                });
+            });
+            it('should interpolate package name');
+        });
     });
 });

Reply via email to