From f5ab6fc60203c54c4f4a7319a716d4c35ef1b326 Mon Sep 17 00:00:00 2001 From: Anis Kadri Date: Fri, 16 Sep 2016 15:41:20 -0700 Subject: [PATCH] adding tests for Android Studio This closes #331 --- spec/unit/pluginHandlers/handlers.spec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 08a6275b..be7b95bb 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -64,6 +64,10 @@ describe('android project handler', function() { android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject); expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('libs', 'TestLib.jar'), false); }); + it('should copy files for Android Studio projects', function () { + android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('app', 'libs', 'TestLib.jar'), false); + }); }); describe('of elements', function() { @@ -84,6 +88,12 @@ describe('android project handler', function() { .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java', temp, path.join('src/com/phonegap/plugins/dummyplugin/DummyPlugin.java'), false); }); + it('should install source files to the right location for Android Studio projects', function() { + android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy) + .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java', temp, path.join('app/src/main/java/com/phonegap/plugins/dummyplugin/DummyPlugin.java'), false); + }); + it('should throw if source file cannot be found', function() { common.__set__('copyFile', copyFileOrig); expect(function() { @@ -240,6 +250,11 @@ describe('android project handler', function() { android['lib-file'].uninstall(valid_libs[0], dummyPluginInfo, dummyProject); expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('libs/TestLib.jar')); }); + it('should remove jar files for Android Studio projects', function () { + android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject, {android_studio:true}); + android['lib-file'].uninstall(valid_libs[0], dummyPluginInfo, dummyProject, {android_studio:true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestLib.jar')); + }); }); describe('of elements', function(done) { @@ -256,6 +271,11 @@ describe('android project handler', function() { android['source-file'].uninstall(valid_source[0], dummyPluginInfo, dummyProject); expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('src/com/phonegap/plugins/dummyplugin/DummyPlugin.java')); }); + it('should remove stuff by calling common.deleteJava for Android Studio projects', function() { + android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject, {android_studio:true}); + android['source-file'].uninstall(valid_source[0], dummyPluginInfo, dummyProject, {android_studio:true}); + expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/java/com/phonegap/plugins/dummyplugin/DummyPlugin.java')); + }); }); describe('of elements', function() {