fixjasmine : CB-12018 : labeled and updated tests to work with jasmine (spyOn and...
authoraudreyso <auso@adobe.com>
Wed, 14 Dec 2016 17:33:47 +0000 (09:33 -0800)
committeraudreyso <auso@adobe.com>
Tue, 10 Jan 2017 19:14:05 +0000 (11:14 -0800)
package.json
spec/ActionStack.spec.js
spec/CordovaCheck.spec.js
spec/CordovaLogger.spec.js
spec/PlatformJson.spec.js

index c96eac4..98ffb2d 100644 (file)
@@ -39,7 +39,7 @@
   },
   "devDependencies": {
     "istanbul": "^0.4.5",
-    "jasmine-node": "^1.14.5",
+    "jasmine": "^2.5.2",
     "jshint": "^2.8.0",
     "promise-matchers": "^0.9.6",
     "rewire": "^2.5.1"
index 5fb6819..b432e21 100644 (file)
@@ -48,7 +48,7 @@ describe('action-stack', function() {
             var first_reverter = jasmine.createSpy();
             var first_reverter_args = [true];
             var process_err = new Error('process_err');
-            var second_spy = jasmine.createSpy().andCallFake(function() {
+            var second_spy = jasmine.createSpy().and.callFake(function() {
                 throw process_err;
             });
             var second_args = [2];
index a1f37fa..c075f7a 100644 (file)
@@ -30,11 +30,12 @@ describe('findProjectRoot method', function() {
         process.env.PWD = origPWD;
         process.chdir(cwd);
     });
+function removeDir(someDirectory) {
+    shell.rm('-rf', someDirectory);
+}
     it('should return false if it hits the home directory', function() {
         var somedir = path.join(home, 'somedir');
-        this.after(function() {
-            shell.rm('-rf', somedir);
-        });
+        removeDir(somedir);
         shell.mkdir(somedir);
         expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false);
     });
@@ -45,9 +46,7 @@ describe('findProjectRoot method', function() {
     it('should return the first directory it finds with a .cordova folder in it', function() {
         var somedir = path.join(home,'somedir');
         var anotherdir = path.join(somedir, 'anotherdir');
-        this.after(function() {
-            shell.rm('-rf', somedir);
-        });
+        removeDir(somedir);
         shell.mkdir('-p', anotherdir);
         shell.mkdir('-p', path.join(somedir, 'www', 'config.xml'));
         expect(CordovaCheck.findProjectRoot(somedir)).toEqual(somedir);
@@ -56,9 +55,7 @@ describe('findProjectRoot method', function() {
         delete process.env.PWD;
         var somedir = path.join(home,'somedir');
         var anotherdir = path.join(somedir, 'anotherdir');
-        this.after(function() {
-            shell.rm('-rf', somedir);
-        });
+        removeDir(somedir);
         shell.mkdir('-p', anotherdir);
         shell.mkdir('-p', path.join(somedir, 'www'));
         shell.mkdir('-p', path.join(somedir, 'config.xml'));
@@ -68,9 +65,7 @@ describe('findProjectRoot method', function() {
     it('should use PWD when available', function() {
         var somedir = path.join(home,'somedir');
         var anotherdir = path.join(somedir, 'anotherdir');
-        this.after(function() {
-            shell.rm('-rf', somedir);
-        });
+        removeDir(somedir);
         shell.mkdir('-p', anotherdir);
         shell.mkdir('-p', path.join(somedir, 'www', 'config.xml'));
         process.env.PWD = anotherdir;
@@ -80,9 +75,7 @@ describe('findProjectRoot method', function() {
     it('should use cwd as a fallback when PWD is not a cordova dir', function() {
         var somedir = path.join(home,'somedir');
         var anotherdir = path.join(somedir, 'anotherdir');
-        this.after(function() {
-            shell.rm('-rf', somedir);
-        });
+        removeDir(somedir);
         shell.mkdir('-p', anotherdir);
         shell.mkdir('-p', path.join(somedir, 'www', 'config.xml'));
         process.env.PWD = path.sep;
@@ -92,9 +85,7 @@ describe('findProjectRoot method', function() {
     it('should ignore platform www/config.xml', function() {
         var somedir = path.join(home,'somedir');
         var anotherdir = path.join(somedir, 'anotherdir');
-        this.after(function() {
-            shell.rm('-rf', somedir);
-        });
+        removeDir(somedir);
         shell.mkdir('-p', anotherdir);
         shell.mkdir('-p', path.join(anotherdir, 'www', 'config.xml'));
         shell.mkdir('-p', path.join(somedir, 'www'));
index 5c27db1..035d717 100644 (file)
@@ -99,7 +99,7 @@ describe('CordovaLogger class', function() {
                 };
 
                 var listenerSpy = jasmine.createSpy('listenerSpy')
-                .andCallFake(function (eventName) {
+                .and.callFake(function (eventName) {
                     eventName = eventNamesExclusions[eventName] || eventName;
                     expect(logger.levels[eventName]).toBeDefined();
                 });
@@ -116,7 +116,7 @@ describe('CordovaLogger class', function() {
                 var spy = jasmine.createSpyObj(name, cursorMethods);
 
                 // Make spy methods chainable, as original Cursor acts
-                cursorMethods.forEach(function (method) { spy[method].andReturn(spy); });
+                cursorMethods.forEach(function (method) { spy[method].and.returnValue(spy); });
 
                 return spy;
             }
@@ -153,7 +153,7 @@ describe('CordovaLogger class', function() {
 
             it('should handle CordovaError instances separately from Error ones', function () {
                 var errorMock = new CordovaError();
-                spyOn(errorMock, 'toString').andReturn('error_message');
+                spyOn(errorMock, 'toString').and.returnValue('error_message');
 
                 logger.setLevel('verbose').log('verbose', errorMock);
                 expect(errorMock.toString).toHaveBeenCalled();
index c9310a2..293b51d 100644 (file)
@@ -43,7 +43,7 @@ describe('PlatformJson class', function() {
             fakePlugin = jasmine.createSpyObj('fakePlugin', ['getJsModules']);\r
             fakePlugin.id = 'fakeId';\r
             fakePlugin.version = '1.0.0';\r
-            fakePlugin.getJsModules.andReturn([FAKE_MODULE]);\r
+            fakePlugin.getJsModules.and.returnValue([FAKE_MODULE]);\r
         });\r
         \r
         describe('addPluginMetadata method', function () {\r