On Tue Feb 25 03:24 AM, Gert-Jan Braas wrote:
> I've added some testing for firefoxos in plugman, but am a bit stuck on
> the
> uninstall handler.
> 
> test:
>          describe('of <source-file> elements', function() {
>              it('should remove stuff by calling common.removeFile',
> function(done) {
>                  var s = spyOn(common, 'removeFile');
> 
>                  install('firefoxos', temp, dummyplugin, plugins_dir, {})
>                  .then(function() {
>                      var source = copyArray(valid_source);
>                      firefoxos['source-file'].uninstall(source[0], temp);
>                      expect(s).toHaveBeenCalledWith(temp,
> path.join('src', 'plugins', 'dummyplugin', 'DummyPlugin.js'));
>                      done();
>                   });
>              });
>          });
> 

Jasmine runs synchronously, so you need to 'waitsFor' promise:

            runs(function() {
                setDonePromise( install('firefoxos', temp, dummyplugin, 
plugins_dir, {})  )
            });
            waitsFor(function() { return done; }, 'install promise never 
resolved', 200);
            runs(function() {
        var source = copyArray(valid_source);
         firefoxos['source-file'].uninstall(source[0], temp);
        expect(s).toHaveBeenCalledWith(temp,path.join('src', 'plugins', 
'dummyplugin', 'DummyPlugin.js'));            
            });

This example might help:
https://github.com/jbondc/cordova-plugman/blob/master/spec/install.spec.js#L115

>   - how is e.g.
>       require('../plugman').emit('verbose', 'Install complete for ' +
> plugin_id + ' on ' + platform + '.');
>     controled? can i set the emit level and where can i find it's output?


It's a wrapper for node's event emitter:
https://github.com/apache/cordova-plugman/blob/master/src/events.js
https://github.com/jbondc/cordova-plugman/blob/master/plugman.js#L58

By itself it doesn't "log" anything, just tracks events. You to map events to 
console.log()

An example here:
https://github.com/jbondc/cordova-plugman/blob/master/spec/common.js

cd spec
node-jasmine test.spec.js -d verbose

> Can it be used running tests (npm test)?

Would be nice, npm parses the commands on its own so doesn’t delegate any flags 
etc.. related to:
https://github.com/npm/npm/issues/3494

Reply via email to