Github user filmaj commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/567#discussion_r123500548
  
    --- Diff: spec-cordova/prepare.spec.js ---
    @@ -63,103 +63,103 @@ describe('cordova/prepare', function () {
                 spyOn(cordova_config, 'read').and.returnValue({});
                 spyOn(restore, 
'installPlatformsFromConfigXML').and.returnValue(Q());
                 spyOn(restore, 
'installPluginsFromConfigXML').and.returnValue(Q());
    -            
    +            spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
    +            spyOn(util, 'preProcessOptions').and.callFake(function 
(options) {
    +                var platforms = options.platforms || [];
    +                return {'platforms':platforms};
    +            });
                 spyOn(prepare, 'preparePlatforms').and.returnValue(Q);
             });
             describe('failure', function () {
    -            it('should invoke util.preProcessOptions as preflight task 
checker, which, if fails, should trigger promise rejection and only fire the 
before_prepare hook', function(done) {
    -                spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
    -                spyOn(util, 'preProcessOptions').and.throwError();
    -                prepare({}).fail(function(err) {
    -                    expect(err).toBeDefined();
    -                    
expect(HooksRunner.prototype.fire.calls.count()).toBe(1);
    -                    
expect(HooksRunner.prototype.fire.calls.argsFor(0)[0]).toEqual('before_prepare');
    -                    done();
    +            it('should invoke util.preProcessOptions as preflight task 
checker, which, if fails, should trigger promise rejection and only fire the 
before_prepare hook', function (done) {
    +                util.preProcessOptions.and.callFake(function () {
    +                    throw new Error('preProcessOption error'); 
                     });
    +                prepare({}).then(function () {
    +                    fail('unexpected failure handler invoked');
    +                }).fail(function (e) {
    +                    expect(e.message).toBe('preProcessOption error');
    +                    
expect(HooksRunner.prototype.fire).toHaveBeenCalledWith('before_prepare', 
jasmine.any(Object));
    +                }).done(done);
                 });
    -            it('should invoke util.cdProjectRoot as a preflight task 
checker, which, if fails, should trigger a promise rejection and fire no 
hooks', function(done) {
    -                spyOn(util, 'cdProjectRoot').and.throwError();
    -                prepare({}).fail(function(err) {
    -                    expect(err).toBeDefined();
    -                    
expect(HooksRunner.prototype.fire.calls.any()).toBe(false);
    -                    done();
    +            it('should invoke util.cdProjectRoot as a preflight task 
checker, which, if fails, should trigger a promise rejection and fire no 
hooks', function (done) {
    +                util.cdProjectRoot.and.callFake(function () {
    +                    throw new Error('cdProjectRoot error');
                     });
    +                prepare({}).then(function () { 
    +                    fail('unexpected failure handler invoked');
    +                }).fail(function (e) {
    +                    expect(e.message).toBe('cdProjectRoot error');
    +                    
expect(HooksRunner.prototype.fire).not.toHaveBeenCalledWith();
    +                }).done(done);
                 });
             });
     
             describe('success', function () {
    -            beforeEach(function () {
    -                spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
    -                spyOn(util, 
'preProcessOptions').and.callFake(function(options) {
    -                    let platforms = options.platforms || [];
    -                    return {'platforms':platforms};
    -                });
    -            });
    -            it('should fire the before_prepare hook and provide platform 
and path information as arguments', function(done) {
    -                prepare({}).then(function() {
    -                    
expect(HooksRunner.prototype.fire.calls.argsFor(0)[0]).toEqual('before_prepare');
    -                    done();
    -                });
    +            it('should fire the before_prepare hook and provide platform 
and path information as arguments', function (done) {
    +                prepare({}).then(function () {
    +                    
expect(HooksRunner.prototype.fire).toHaveBeenCalledWith('before_prepare', 
jasmine.any(Object));
    +                }).fail(function (e) {
    +                    fail('unexpected failure handler invoked');
    +                    console.error(e);
    +                }).done(done);
                 });
    -            it('should invoke restore module\'s 
installPlatformsFromConfigXML method', function(done) {
    -                prepare({}).then(function() {
    +            it('should invoke restore module\'s 
installPlatformsFromConfigXML method', function (done) {
    +                prepare({}).then(function () {
                         
expect(restore.installPlatformsFromConfigXML).toHaveBeenCalled();
    -                    done();
    -                }).fail(function(err){
    -                    expect(err).toBeUndefined();
    -                    done();
    -                });
    +                }).fail(function (e) {
    +                    fail('unexpected failure handler invoked');
    +                    console.error(e);
    +                }).done(done);
                 });
    -            it('should retrieve PlatformApi instances for each platform 
provided', function(done) {
    -                prepare({'platforms':['android', 'ios']}).then(function() {
    -                    expect(platforms.getPlatformApi.calls.count()).toBe(4);
    -                    
expect(platforms.getPlatformApi.calls.argsFor(0)[0]).toBe('android');
    -                    
expect(platforms.getPlatformApi.calls.argsFor(0)[1]).toBe('/some/path/platforms/android');
    -                    
expect(platforms.getPlatformApi.calls.argsFor(1)[0]).toBe('ios');
    -                    
expect(platforms.getPlatformApi.calls.argsFor(1)[1]).toBe('/some/path/platforms/ios');
    -                    
expect(platforms.getPlatformApi.calls.argsFor(2)[0]).toBe('android');
    -                    
expect(platforms.getPlatformApi.calls.argsFor(3)[0]).toBe('ios');
    -                    done();
    -                }).fail(function(err){
    -                    expect(err).toBeUndefined();
    -                    done();
    -                });
    +            it('should retrieve PlatformApi instances for each platform 
provided', function (done) {
    +                prepare({'platforms':['android', 'ios']}).then(function () 
{
    +                    
expect(platforms.getPlatformApi).toHaveBeenCalledTimes(4);
    --- End diff --
    
    O I didn't know this was available!


---
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

Reply via email to