cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [2/3] git commit: Add tests for fetch.checkID()
Date Fri, 20 Jun 2014 21:51:16 GMT
Add tests for fetch.checkID()


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

Branch: refs/heads/master
Commit: f6584895a6136d865aa26ac27de88b0f5e080c10
Parents: 4cccc6a
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Mon May 5 10:02:26 2014 +0400
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Mon May 5 10:02:26 2014 +0400

----------------------------------------------------------------------
 spec/fetch.spec.js | 45 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/f6584895/spec/fetch.spec.js
----------------------------------------------------------------------
diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js
index 2a0b660..6613865 100644
--- a/spec/fetch.spec.js
+++ b/spec/fetch.spec.js
@@ -23,7 +23,7 @@ describe('fetch', function() {
         var xml, rm, sym, mkdir, cp, save_metadata;
         beforeEach(function() {
             xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
-                getroot:function() { return {attrib:{id:'id'}};}
+                getroot:function() { return {attrib:{id:'id', version:'version'}};}
             });
             rm = spyOn(shell, 'rm');
             sym = spyOn(fs, 'symlinkSync');
@@ -62,6 +62,19 @@ describe('fetch', function() {
                 expect(1).toBe(1);
             });
         });
+        it('should fail when the expected ID with version specified doesn\'t match', function(done)
{
+            fetch(test_plugin, temp, { expected_id: 'id@wrongVersion' })
+            .then(function() {
+                expect('this call').toBe('fail');
+            }, function(err) {
+                expect(''+err).toContain('Expected fetched plugin to have ID "id@wrongVersion"
but got "id@version".');
+            }).fin(done);
+        });
+        it('should succeed when the plugin version specified is correct', function(done)
{
+            wrapper(fetch(test_plugin, temp, { expected_id: 'id@version' }), done, function()
{
+                expect(1).toBe(1);
+            });
+        });
     });
     describe('git plugins', function() {
         var clone, save_metadata, done, xml;
@@ -75,7 +88,7 @@ describe('fetch', function() {
             save_metadata = spyOn(metadata, 'save_fetch_metadata');
             done = false;
             xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
-                getroot:function() { return {attrib:{id:'id'}};}
+                getroot:function() { return {attrib:{id:'id', version:'version'}};}
             });
         });
         it('should call clonePluginGitRepo for https:// and git:// based urls', function()
{
@@ -168,18 +181,31 @@ describe('fetch', function() {
                 expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but
got "id".');
             }).fin(done);
         });
+        it('should fail when the expected ID with version specified doesn\'t match', function(done)
{
+            fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id@wrongVersion'
})
+            .then(function() {
+                expect('this call').toBe('fail');
+            }, function(err) {
+                expect(''+err).toContain('Expected fetched plugin to have ID "id@wrongVersion"
but got "id@version".');
+            }).fin(done);
+        });
         it('should succeed when the expected ID is correct', function(done) {
             wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id:
'id' }), done, function() {
                 expect(1).toBe(1);
             });
         });
+        it('should succeed when the plugin version specified is correct', function(done)
{
+            wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id:
'id@version' }), done, function() {
+                expect(1).toBe(1);
+            });
+        });
     });
     describe('registry plugins', function() {
         var pluginId = 'dummyplugin', sFetch;
         var xml, rm, sym, mkdir, cp, save_metadata;
         beforeEach(function() {
             xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
-                getroot:function() { return {attrib:{id:'id'}};}
+                getroot:function() { return {attrib:{id:'id', version:'version'}};}
             });
             rm = spyOn(shell, 'rm');
             sym = spyOn(fs, 'symlinkSync');
@@ -202,10 +228,23 @@ describe('fetch', function() {
                 expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but
got "id".');
             }).fin(done);
         });
+        it('should fail when the expected ID with version specified doesn\'t match', function(done)
{
+            fetch(pluginId, temp, { expected_id: 'id@wrongVersion' })
+            .then(function() {
+                expect('this call').toBe('fail');
+            }, function(err) {
+                expect(''+err).toContain('Expected fetched plugin to have ID "id@wrongVersion"
but got "id@version".');
+            }).fin(done);
+        });
         it('should succeed when the expected ID is correct', function(done) {
             wrapper(fetch(pluginId, temp, { expected_id: 'id' }), done, function() {
                 expect(1).toBe(1);
             });
         });
+        it('should succeed when the plugin version specified is correct', function(done)
{
+            wrapper(fetch(pluginId, temp, { expected_id: 'id@version' }), done, function()
{
+                expect(1).toBe(1);
+            });
+        });
     });
 });


Mime
View raw message