You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/07/07 15:36:36 UTC

[GitHub] [cordova-android] timbru31 commented on a change in pull request #1013: test(pluginHandlers/common): better setup & teardown

timbru31 commented on a change in pull request #1013:
URL: https://github.com/apache/cordova-android/pull/1013#discussion_r450958324



##########
File path: spec/unit/pluginHandlers/common.spec.js
##########
@@ -35,38 +36,39 @@ var deleteJava = common.__get__('deleteJava');
 var copyNewFile = common.__get__('copyNewFile');
 
 describe('common platform handler', function () {
+    afterEach(() => {
+        fs.removeSync(test_dir);
+        fs.removeSync(non_plugin_file);
+    });
+
     describe('copyFile', function () {
         it('Test#001 : should throw if source path not found', function () {
-            fs.removeSync(src);
             expect(function () { copyFile(test_dir, src, project_dir, dest); })
                 .toThrow(new Error('"' + src + '" not found!'));
         });
 
         it('Test#002 : should throw if src not in plugin directory', function () {
             fs.ensureDirSync(project_dir);
-            fs.writeFileSync(non_plugin_file, 'contents', 'utf-8');
+            fs.outputFileSync(non_plugin_file, 'contents');
             var outside_file = '../non_plugin_file';
             expect(function () { copyFile(test_dir, outside_file, project_dir, dest); })
                 .toThrow(new Error('File "' + path.resolve(test_dir, outside_file) + '" is located outside the plugin directory "' + test_dir + '"'));
-            fs.removeSync(test_dir);
         });
 
         it('Test#003 : should allow symlink src, if inside plugin', function () {
-            fs.ensureDirSync(java_dir);
-            fs.writeFileSync(java_file, 'contents', 'utf-8');
+            fs.outputFileSync(java_file, 'contents');
 
             // This will fail on windows if not admin - ignore the error in that case.
             if (ignoreEPERMonWin32(java_file, symlink_file)) {
                 return;
             }
 
             copyFile(test_dir, symlink_file, project_dir, dest);
-            fs.removeSync(project_dir);

Review comment:
       Won't this leave traces of the test behind? It's not cleared via the afterEach hook.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org