@@ -24,7 +24,8 @@ var uninstall = require('../src/plugman/uninstall'),
2424 actions = require ( '../src/plugman/util/action-stack' ) ,
2525 PlatformJson = require ( '../src/plugman/util/PlatformJson' ) ,
2626 events = require ( '../src/events' ) ,
27- plugman = require ( '../src/plugman/plugman' ) ,
27+ plugman = require ( '../src/plugman/plugman' ) ,
28+ HooksRunner = require ( '../src/hooks/HooksRunner' ) ,
2829 common = require ( './common' ) ,
2930 fs = require ( 'fs' ) ,
3031 path = require ( 'path' ) ,
@@ -41,7 +42,8 @@ var uninstall = require('../src/plugman/uninstall'),
4142 plugins_install_dir2 = path . join ( project2 , 'cordova' , 'plugins' ) ,
4243
4344 plugins = {
44- 'org.test.plugins.dummyplugin' : path . join ( plugins_dir , 'org.test.plugins.dummyplugin' ) ,
45+ 'org.test.plugins.dummyplugin' : path . join ( plugins_dir , 'org.test.plugins.dummyplugin' ) ,
46+ 'org.test.plugin-with-hooks' : path . join ( plugins_dir , 'org.test.plugin-with-hooks' ) ,
4547 'A' : path . join ( plugins_dir , 'dependencies' , 'A' ) ,
4648 'C' : path . join ( plugins_dir , 'dependencies' , 'C' )
4749 } ,
@@ -64,6 +66,8 @@ describe('start', function() {
6466 promise = Q ( )
6567 . then ( function ( ) {
6668 return install ( 'android' , project , plugins [ 'org.test.plugins.dummyplugin' ] ) ;
69+ } ) . then ( function ( ) {
70+ return install ( 'android' , project , plugins [ 'org.test.plugin-with-hooks' ] ) ;
6771 } ) . then ( function ( ) {
6872 return install ( 'android' , project , plugins [ 'A' ] ) ;
6973 } ) . then ( function ( ) {
@@ -97,7 +101,7 @@ describe('uninstallPlatform', function() {
97101 add_to_queue = spyOn ( PlatformJson . prototype , 'addUninstalledPluginToPrepareQueue' ) ;
98102 done = false ;
99103 } ) ;
100- describe ( 'success' , function ( ) {
104+ describe ( 'success' , function ( ) {
101105 it ( 'should call prepare after a successful uninstall' , function ( ) {
102106 runs ( function ( ) {
103107 uninstallPromise ( uninstall . uninstallPlatform ( 'android' , project , dummy_id ) ) ;
@@ -177,7 +181,7 @@ describe('uninstallPlugin', function() {
177181 done = false ;
178182 } ) ;
179183 describe ( 'with dependencies' , function ( ) {
180-
184+
181185 it ( 'should delete all dependent plugins' , function ( ) {
182186 runs ( function ( ) {
183187 uninstallPromise ( uninstall . uninstallPlugin ( 'A' , plugins_install_dir ) ) ;
@@ -234,15 +238,26 @@ describe('uninstallPlugin', function() {
234238} ) ;
235239
236240describe ( 'uninstall' , function ( ) {
237- var fsWrite , rm , add_to_queue ;
241+ var fsWrite , rm , add_to_queue , fire ;
238242
239243 beforeEach ( function ( ) {
240244 fsWrite = spyOn ( fs , 'writeFileSync' ) . andReturn ( true ) ;
241245 rm = spyOn ( shell , 'rm' ) . andReturn ( true ) ;
242246 add_to_queue = spyOn ( PlatformJson . prototype , 'addUninstalledPluginToPrepareQueue' ) ;
247+ fire = spyOn ( HooksRunner . prototype , 'fire' ) . andReturn ( Q ( ) ) ;
243248 done = false ;
244249 } ) ;
245250 describe ( 'success' , function ( ) {
251+ it ( 'should fire hooks on plugin successful uninstalled' , function ( ) {
252+ runs ( function ( ) {
253+ uninstallPromise ( uninstall ( 'android' , project , plugins [ 'org.test.plugin-with-hooks' ] ) ) ;
254+ } ) ;
255+ waitsFor ( function ( ) { return done ; } , 'promise never resolved' , 200 ) ;
256+ runs ( function ( ) {
257+ expect ( fire ) . toHaveBeenCalled ( ) ;
258+ } ) ;
259+ } ) ;
260+
246261 it ( 'should call the config-changes module\'s add_uninstalled_plugin_to_prepare_queue method after processing an install' , function ( ) {
247262 runs ( function ( ) {
248263 uninstallPromise ( uninstall ( 'android' , project , plugins [ 'org.test.plugins.dummyplugin' ] ) ) ;
@@ -285,6 +300,10 @@ describe('end', function() {
285300 function ( ) {
286301 return uninstall ( 'android' , project , plugins [ 'org.test.plugins.dummyplugin' ] ) ;
287302 }
303+ ) . then (
304+ function ( ) {
305+ return uninstall ( 'android' , project , plugins [ 'org.test.plugin-with-hooks' ] ) ;
306+ }
288307 ) . then (
289308 function ( ) {
290309 // Fails... A depends on
0 commit comments