Added spec tests for the aliased commands.

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/9c1a6fc6
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/9c1a6fc6
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/9c1a6fc6

Branch: refs/heads/cordova-client
Commit: 9c1a6fc6271e537bb691d7c8e420ceba84aec97a
Parents: 38f180f
Author: Darryl Pogue <dvpdin...@gmail.com>
Authored: Tue Oct 2 22:51:16 2012 -0700
Committer: Darryl Pogue <dvpdin...@gmail.com>
Committed: Tue Oct 2 22:51:16 2012 -0700

----------------------------------------------------------------------
 spec/platform.spec.js |  113 +++++++++++++++++--------------
 spec/plugin.spec.js   |  160 +++++++++++++++++++++++---------------------
 2 files changed, 145 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/9c1a6fc6/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index a6fa8be..03128d8 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -47,38 +47,42 @@ describe('platform command', function() {
         }).toThrow();
     });
 
-    describe('`ls`', function() {
-        beforeEach(function() {
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-        });
+    var listing_tests = function(_invocation) {
+        return function() {
+            beforeEach(function() {
+                cordova.create(tempDir);
+                process.chdir(tempDir);
+            });
 
-        afterEach(function() {
-            process.chdir(cwd);
-        });
+            afterEach(function() {
+                process.chdir(cwd);
+            });
 
-        it('should list out no platforms for a fresh project', function() {
-            expect(cordova.platform('ls').length).toEqual(0);
-        });
+            it('should list out no platforms for a fresh project', function() {
+                expect(cordova.platform(_invocation).length).toEqual(0);
+            });
 
-        it('should list out added platforms in a project', function() {
-            var cbtwo = jasmine.createSpy();
-            var cb = jasmine.createSpy();
+            it('should list out added platforms in a project', function() {
+                var cbtwo = jasmine.createSpy();
+                var cb = jasmine.createSpy();
 
-            runs(function() {
-                cordova.platform('add', 'android', cb);
-            });
-            waitsFor(function() { return cb.wasCalled; }, "create callback");
-            runs(function() {
-                expect(cordova.platform('ls')[0]).toEqual('android');
-                cordova.platform('add', 'ios', cbtwo);
-            });
-            waitsFor(function() { return cbtwo.wasCalled; }, "create callback 
number two");
-            runs(function() {
-                expect(cordova.platform('ls')[1]).toEqual('ios');
+                runs(function() {
+                    cordova.platform('add', 'android', cb);
+                });
+                waitsFor(function() { return cb.wasCalled; }, "create 
callback");
+                runs(function() {
+                    
expect(cordova.platform(_invocation)[0]).toEqual('android');
+                    cordova.platform('add', 'ios', cbtwo);
+                });
+                waitsFor(function() { return cbtwo.wasCalled; }, "create 
callback number two");
+                runs(function() {
+                    expect(cordova.platform(_invocation)[1]).toEqual('ios');
+                });
             });
-        });
-    });
+        };
+    };
+    describe('`ls`', listing_tests('ls'));
+    describe('`list`', listing_tests('list'));
 
     describe('`add`', function() {
         beforeEach(function() {
@@ -195,33 +199,38 @@ describe('platform command', function() {
             });
         });
     });
-    describe('remove', function() {
-        beforeEach(function() {
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-        });
-
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-
-        it('should remove a supported and added platform', function() {
-            var cb = jasmine.createSpy();
-            var cbone = jasmine.createSpy();
 
-            runs(function() {
-                cordova.platform('add', 'ios', cbone);
+    var removing_tests = function(_invocation) {
+        return function() {
+            beforeEach(function() {
+                cordova.create(tempDir);
+                process.chdir(tempDir);
             });
-            waitsFor(function() { return cbone.wasCalled; }, "ios create 
callback");
-            runs(function() {
-                cordova.platform('add', 'android', cb);
+
+            afterEach(function() {
+                process.chdir(cwd);
             });
-            waitsFor(function() { return cb.wasCalled; }, "android create 
callback");
-            runs(function() {
-                cordova.platform('remove', 'android');
-                expect(cordova.platform('ls').length).toEqual(1);
-                expect(cordova.platform('ls')[0]).toEqual('ios');
+
+            it('should remove a supported and added platform', function() {
+                var cb = jasmine.createSpy();
+                var cbone = jasmine.createSpy();
+
+                runs(function() {
+                    cordova.platform('add', 'ios', cbone);
+                });
+                waitsFor(function() { return cbone.wasCalled; }, "ios create 
callback");
+                runs(function() {
+                    cordova.platform('add', 'android', cb);
+                });
+                waitsFor(function() { return cb.wasCalled; }, "android create 
callback");
+                runs(function() {
+                    cordova.platform(_invocation, 'android');
+                    expect(cordova.platform('ls').length).toEqual(1);
+                    expect(cordova.platform('ls')[0]).toEqual('ios');
+                });
             });
-        });
-    });
+        };
+    };
+    describe('`rm`', removing_tests('rm'));
+    describe('`remove`', removing_tests('remove'));
 });

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/9c1a6fc6/spec/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
index 0289f71..b6c9ae4 100644
--- a/spec/plugin.spec.js
+++ b/spec/plugin.spec.js
@@ -41,21 +41,25 @@ describe('plugin command', function() {
         }).toThrow();
     });
 
-    describe('`ls`', function() {
-        beforeEach(function() {
-            cordova.create(tempDir);
-        });
+    var listing_tests = function(_invocation) {
+        return function() {
+            beforeEach(function() {
+                cordova.create(tempDir);
+            });
 
-        afterEach(function() {
-            process.chdir(cwd);
-        });
+            afterEach(function() {
+                process.chdir(cwd);
+            });
 
-        it('should list out no plugins for a fresh project', function() {
-            process.chdir(tempDir);
+            it('should list out no plugins for a fresh project', function() {
+                process.chdir(tempDir);
 
-            expect(cordova.plugin('ls')).toEqual('No plugins added. Use 
`cordova plugin add <plugin>`.');
-        });
-    });
+                expect(cordova.plugin(_invocation)).toEqual('No plugins added. 
Use `cordova plugin add <plugin>`.');
+            });
+        };
+    };
+    describe('`ls`', listing_tests('ls'));
+    describe('`list`', listing_tests('list'));
 
     describe('`add`', function() {
         beforeEach(function() {
@@ -153,76 +157,80 @@ describe('plugin command', function() {
         });
     });
 
-    describe('`remove`', function() {
-        beforeEach(function() {
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-        });
+    var removing_tests = function(_invocation) {
+        return function() {
+            beforeEach(function() {
+                cordova.create(tempDir);
+                process.chdir(tempDir);
+            });
 
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-        describe('failure', function() {
-            it('should throw if your app has no platforms added', function() {
-                expect(function() {
-                    cordova.plugin('remove', testPlugin);
-                }).toThrow('You need at least one platform added to your app. 
Use `cordova platform add <platform>`.');
+            afterEach(function() {
+                process.chdir(cwd);
             });
-            it('should throw if plugin is not added to project', function() {
-                var cb = jasmine.createSpy();
-                runs(function() {
-                    cordova.platform('add', 'ios', cb);
-                });
-                waitsFor(function() { return cb.wasCalled; }, 'ios platform 
add');
-                runs(function() {
+            describe('failure', function() {
+                it('should throw if your app has no platforms added', 
function() {
                     expect(function() {
-                        cordova.plugin('remove', 'test', function() {});
-                    }).toThrow('Plugin "test" not added to project.');
-                });
-            });
-        });
-        describe('success', function() {
-            it('should remove plugin www assets from project www folder', 
function() {
-                var cb = jasmine.createSpy();
-                var pluginCb = jasmine.createSpy();
-                var removeCb = jasmine.createSpy();
-                runs(function() {
-                    cordova.platform('add', 'ios', cb);
-                });
-                waitsFor(function() { return cb.wasCalled; }, 'ios platform 
add');
-                runs(function() {
-                    cordova.plugin('add', testPlugin, pluginCb);
-                });
-                waitsFor(function() { return pluginCb.wasCalled; }, 'test 
plugin add');
-                runs(function() {
-                    cordova.plugin('remove', 'test', removeCb);
-                });
-                waitsFor(function() { return removeCb.wasCalled; }, 'test 
plugin remove');
-                runs(function() {
-                    expect(fs.existsSync(path.join(tempDir, 'www', 
'test.js'))).toBe(false);
+                        cordova.plugin('rm', testPlugin);
+                    }).toThrow('You need at least one platform added to your 
app. Use `cordova platform add <platform>`.');
+                });
+                it('should throw if plugin is not added to project', 
function() {
+                    var cb = jasmine.createSpy();
+                    runs(function() {
+                        cordova.platform('add', 'ios', cb);
+                    });
+                    waitsFor(function() { return cb.wasCalled; }, 'ios 
platform add');
+                    runs(function() {
+                        expect(function() {
+                            cordova.plugin('rm', 'test', function() {});
+                        }).toThrow('Plugin "test" not added to project.');
+                    });
                 });
             });
-            it('should remove the full plugin from the plugins directory', 
function() {
-                var cb = jasmine.createSpy();
-                var pluginCb = jasmine.createSpy();
-                var removeCb = jasmine.createSpy();
-                runs(function() {
-                    cordova.platform('add', 'ios', cb);
-                });
-                waitsFor(function() { return cb.wasCalled; }, 'ios platform 
add');
-                runs(function() {
-                    cordova.plugin('add', testPlugin, pluginCb);
-                });
-                waitsFor(function() { return pluginCb.wasCalled; }, 'test 
plugin add');
-                runs(function() {
-                    cordova.plugin('remove', 'test', removeCb);
-                });
-                waitsFor(function() { return removeCb.wasCalled; }, 'test 
plugin remove');
-                runs(function() {
-                    expect(fs.existsSync(path.join(tempDir, 'plugins', 
'test'))).toBe(false);
+            describe('success', function() {
+                it('should remove plugin www assets from project www folder', 
function() {
+                    var cb = jasmine.createSpy();
+                    var pluginCb = jasmine.createSpy();
+                    var removeCb = jasmine.createSpy();
+                    runs(function() {
+                        cordova.platform('add', 'ios', cb);
+                    });
+                    waitsFor(function() { return cb.wasCalled; }, 'ios 
platform add');
+                    runs(function() {
+                        cordova.plugin('add', testPlugin, pluginCb);
+                    });
+                    waitsFor(function() { return pluginCb.wasCalled; }, 'test 
plugin add');
+                    runs(function() {
+                        cordova.plugin('rm', 'test', removeCb);
+                    });
+                    waitsFor(function() { return removeCb.wasCalled; }, 'test 
plugin remove');
+                    runs(function() {
+                        expect(fs.existsSync(path.join(tempDir, 'www', 
'test.js'))).toBe(false);
+                    });
+                });
+                it('should remove the full plugin from the plugins directory', 
function() {
+                    var cb = jasmine.createSpy();
+                    var pluginCb = jasmine.createSpy();
+                    var removeCb = jasmine.createSpy();
+                    runs(function() {
+                        cordova.platform('add', 'ios', cb);
+                    });
+                    waitsFor(function() { return cb.wasCalled; }, 'ios 
platform add');
+                    runs(function() {
+                        cordova.plugin('add', testPlugin, pluginCb);
+                    });
+                    waitsFor(function() { return pluginCb.wasCalled; }, 'test 
plugin add');
+                    runs(function() {
+                        cordova.plugin('rm', 'test', removeCb);
+                    });
+                    waitsFor(function() { return removeCb.wasCalled; }, 'test 
plugin remove');
+                    runs(function() {
+                        expect(fs.existsSync(path.join(tempDir, 'plugins', 
'test'))).toBe(false);
+                    });
                 });
             });
-        });
-    });
+        };
+    };
+    describe('`rm`', removing_tests('rm'));
+    describe('`remove`', removing_tests('remove'));
 });
 

Reply via email to