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

    https://github.com/apache/cordova-lib/pull/584#discussion_r136488898
  
    --- Diff: spec/cordova/plugin/save.spec.js ---
    @@ -54,15 +61,145 @@ describe('cordova/plugin/save', function () {
             });
         });
         describe('happy path', function () {
    -        it('should remove all plugins from config.xml and re-add new ones 
based on those retrieved from fetch.json');
    -        it('should only add top-level plugins to config.xml');
    -        it('should write individual plugin specs to config.xml');
    -        it('should write individual plugin variables to config.xml');
    +        it('should remove all plugins from config.xml and re-add new ones 
based on those retrieved from fetch.json', function (done) {
    +            save(projectRoot).then(function () {
    +                
expect(cfg_parser_mock.prototype.removePlugin).toHaveBeenCalledWith('VRPlugin');
    +                
expect(cfg_parser_mock.prototype.removePlugin).toHaveBeenCalledWith('MastodonSocialPlugin');
    +            }).fail(function (e) {
    +                expect(e).toBeUndefined();
    +                fail('did not expect fail handler to be invoked');
    +            }).done(done);
    +        });
    +
    +        it('should only add top-level plugins to config.xml', function 
(done) {
    +            var fake_fetch_json =
    +                {'VRPlugin': {'source': {
    +                    'type': 'registry',
    +                    'id': 'id'
    +                },
    +                'is_top_level': true
    +                },
    +                'MastodonSocialPlugin': { 'source': {
    +                    'type': 'registry',
    +                    'id': 'id'
    +                },
    +                'is_top_level': false }};
    +
    +            
fs.readFileSync.and.returnValue(JSON.stringify(fake_fetch_json));
    +            save(projectRoot).then(function () {
    +                
expect(cfg_parser_mock.prototype.addPlugin).toHaveBeenCalledWith(Object({ name: 
'VRPlugin' }), [ ]);
    +                expect(cfg_parser_mock.prototype.write).toHaveBeenCalled();
    +            }).fail(function (e) {
    +                expect(e).toBeUndefined();
    +                fail('did not expect fail handler to be invoked');
    +            }).done(done);
    +        });
    +
    +        it('should write individual plugin specs to config.xml', function 
(done) {
    +            var fake_fetch_json =
    +                {'VRPlugin': {'source': {
    +                    'type': 'registry',
    +                    'id': 'id'
    +                },
    +                'is_top_level': true }};
    +            
fs.readFileSync.and.returnValue(JSON.stringify(fake_fetch_json));
    +            spyOn(save, 'getSpec').and.returnValue('1.0.0');
    +            save(projectRoot).then(function () {
    +                
expect(cfg_parser_mock.prototype.addPlugin).toHaveBeenCalledWith(Object({ name: 
'VRPlugin', spec: '1.0.0' }), jasmine.any(Object));
    +                expect(cfg_parser_mock.prototype.write).toHaveBeenCalled();
    +            }).fail(function (e) {
    +                expect(e).toBeUndefined();
    +                fail('did not expect fail handler to be invoked');
    +            }).done(done);
    +        });
    +
    +        it('should write individual plugin variables to config.xml', 
function (done) {
    +            var fake_fetch_json =
    +                {'VRPlugin': {'source': {
    +                    'type': 'registry',
    +                    'id': 'id'
    +                },
    +                'is_top_level': true,
    +                'variables': {
    +                    'var 1': ' '
    +                }}};
    +            
fs.readFileSync.and.returnValue(JSON.stringify(fake_fetch_json));
    +            save(projectRoot).then(function () {
    +                
expect(cfg_parser_mock.prototype.addPlugin).toHaveBeenCalledWith(jasmine.any(Object),
 [ Object({ name: 'var 1', value: ' ' }) ]);
    +                expect(cfg_parser_mock.prototype.write).toHaveBeenCalled();
    +            }).fail(function (e) {
    +                expect(e).toBeUndefined();
    +                fail('did not expect fail handler to be invoked');
    +            }).done(done);
    +        });
         });
         describe('getSpec helper method', function () {
    -        it('should return a plugin source\'s url or path property 
immediately');
    -        it('should return a version if a version was provided to plugin 
id');
    -        it('should return a version that includes scope if scope was part 
of plugin id');
    -        it('should fall back to using PluginInfoProvider to retrieve a 
version as last resort');
    +        it('should return a plugin source\'s url or path property 
immediately', function (done) {
    +            var fake_fetch_json =
    +                {'VRPlugin': {'source': {
    +                    'url': 
'https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git'
    +                },
    +                'is_top_level': true,
    +                'variables': {
    +                    'var 1': ' '
    +                }}};
    +            
fs.readFileSync.and.returnValue(JSON.stringify(fake_fetch_json));
    +            spyOn(save, 'getSpec');
    +            save(projectRoot).then(function (result) {
    +                expect(save.getSpec).toHaveBeenCalledWith(Object({ url: 
'https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git' }), 
'/some/path', 'VRPlugin');
    --- End diff --
    
    I think we need one more expect here. We need to confirm `save.getSpec` 
returned the url. I think you can use `returnValue` or `toEqual`
    
    ```
     
expect(save.getSpec).and.returnValue('https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git')
    ```


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