Github user stevengill commented on a diff in the pull request: https://github.com/apache/cordova-lib/pull/581#discussion_r132758854 --- Diff: spec/cordova/plugin/remove.spec.js --- @@ -32,18 +66,123 @@ describe('cordova/plugin/remove', function () { expect(e.message).toContain('No plugin specified'); }).done(done); }); - it('should require that a provided plugin be installed in the current project'); + + it('should require that a provided plugin be installed in the current project', function (done) { + var opts = { plugins: [ undefined ] }; + remove(projectRoot, 'plugin', hook_mock, opts).then(function () { + fail('success handler unexpectedly invoked'); + }).fail(function (e) { + expect(e.message).toContain('is not present in the project'); + }).done(done); + }); }); describe('happy path', function () { - it('should fire the before_plugin_rm hook'); - it('should call plugman.uninstall.uninstallPlatform for each platform installed in the project and for each provided plugin'); - it('should trigger a prepare if plugman.uninstall.uninstallPlatform returned something falsy'); - it('should call plugman.uninstall.uninstallPlugin once plugin has been uninstalled for each platform'); + it('should fire the before_plugin_rm hook', function (done) { + var opts = { important: 'options', plugins: [] }; + remove(projectRoot, 'cordova-plugin-splashscreen', hook_mock, opts).then(function () { + expect(hook_mock.fire).toHaveBeenCalledWith('before_plugin_rm', opts); + }).fail(function (e) { + fail('fail handler unexpectedly invoked'); + console.error(e); + }).done(done); + }); + + it('should call plugman.uninstall.uninstallPlatform for each platform installed in the project and for each provided plugin', function (done) { + remove.validatePluginId.and.returnValue('cordova-plugin-splashscreen'); + var opts = {important: 'options', plugins: ['cordova-plugin-splashscreen']}; + remove(projectRoot, 'cordova-plugin-splashscreen', hook_mock, opts).then(function () { + expect(plugman.uninstall.uninstallPlatform).toHaveBeenCalled(); + expect(events.emit).toHaveBeenCalledWith('verbose', jasmine.stringMatching('plugman.uninstall on plugin "cordova-plugin-splashscreen" for platform "ios"')); + expect(events.emit).toHaveBeenCalledWith('verbose', jasmine.stringMatching('plugman.uninstall on plugin "cordova-plugin-splashscreen" for platform "android"')); + }).fail(function (e) { + fail('fail handler unexpectedly invoked'); + console.error(e); + }).done(done); + }); + + it('should trigger a prepare if plugman.uninstall.uninstallPlatform returned something falsy', function (done) { + remove.validatePluginId.and.returnValue('cordova-plugin-splashscreen'); + plugman.uninstall.uninstallPlatform.and.returnValue(Q(false)); + var opts = {important: 'options', plugins: ['cordova-plugin-splashscreen']}; + remove(projectRoot, 'cordova-plugin-splashscreen', hook_mock, opts).then(function () { + expect(plugman.uninstall.uninstallPlatform).toHaveBeenCalled(); + expect(events.emit).toHaveBeenCalledWith('verbose', 'Calling prepare.'); --- End diff -- i'd suggest removing this expect event due to my other comment
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org