You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by audreyso <gi...@git.apache.org> on 2017/07/20 18:21:41 UTC

[GitHub] cordova-lib pull request #579: CB-12361 : added tests for save.js

GitHub user audreyso opened a pull request:

    https://github.com/apache/cordova-lib/pull/579

    CB-12361 : added tests for save.js

    <!--
    Please make sure the checklist boxes are all checked before submitting the PR. The checklist
    is intended as a quick reference, for complete details please see our Contributor Guidelines:
    
    http://cordova.apache.org/contribute/contribute_guidelines.html
    
    Thanks!
    -->
    
    ### Platforms affected
    
    
    ### What does this PR do?
    
    
    ### What testing has been done on this change?
    added tests for save.js
    
    ### Checklist
    - [X] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
    - [X] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
    - [X] Added automated test coverage as appropriate for this change.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/audreyso/cordova-lib CB-12361-11

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-lib/pull/579.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #579
    
----

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-lib pull request #579: CB-12361 : added tests for save.js

Posted by stevengill <gi...@git.apache.org>.
Github user stevengill commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/579#discussion_r129981726
  
    --- Diff: spec/cordova/platform/save.spec.js ---
    @@ -0,0 +1,71 @@
    +/**
    +    Licensed to the Apache Software Foundation (ASF) under one
    +    or more contributor license agreements.  See the NOTICE file
    +    distributed with this work for additional information
    +    regarding copyright ownership.  The ASF licenses this file
    +    to you under the Apache License, Version 2.0 (the
    +    "License"); you may not use this file except in compliance
    +    with the License.  You may obtain a copy of the License at
    +    http://www.apache.org/licenses/LICENSE-2.0
    +    Unless required by applicable law or agreed to in writing,
    +    software distributed under the License is distributed on an
    +    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +    KIND, either express or implied.  See the License for the
    +    specific language governing permissions and limitations
    +    under the License.
    +*/
    +
    +var Q = require('q');
    +var rewire = require('rewire');
    +var platform_save = rewire('../../../src/cordova/platform/save');
    +var platform_metadata = require('../../../src/cordova/platform_metadata');
    +var fail;
    +var semver = require('semver');
    +
    +describe('cordova/platform/save', function () {
    +    var hooks_mock;
    +    var projectRoot = '/some/path';
    +    var cfg_parser_mock = function () {};
    +    var cfg_parser_revert_mock;
    +
    +    beforeEach(function () {
    +        spyOn(semver, 'valid');
    +        cfg_parser_mock.prototype = jasmine.createSpyObj('config parser mock', ['write', 'removeEngine', 'addEngine','getEngines']);
    +        cfg_parser_revert_mock = platform_save.__set__('ConfigParser', cfg_parser_mock);
    +        cfg_parser_mock.prototype.getEngines.and.returnValue(['android']);
    +    });
    +
    +    afterEach(function () {
    +        cfg_parser_revert_mock();
    +    });
    +
    +    it('should first remove platforms already in config.xml', function (done) {
    +        platform_save(hooks_mock, projectRoot, {save : true})
    +        .then(function(res){
    +            expect(cfg_parser_mock.prototype.getEngines).toHaveBeenCalled();
    +            expect(cfg_parser_mock.prototype.removeEngine).toHaveBeenCalled();
    +        }).fail(function (err) {
    +            fail('unexpected failure handler invoked!');
    +            console.error(err);
    +        }).done(done);
    +    });
    +
    +    it('add and write to config.xml', function (done) {
    +        spyOn(platform_metadata, 'getPlatformVersions').and.returnValue(Q(['6.3.0']));
    +        semver.valid.and.returnValue('6.0.0');
    +        platform_save(hooks_mock, projectRoot, {save : true})
    +        .then(function(result) {
    +            expect(cfg_parser_mock.prototype.addEngine).toHaveBeenCalledWith(undefined, '~6.0.0');
    +            expect(cfg_parser_mock.prototype.write).toHaveBeenCalled();
    +        }).fail(function (err) {
    +            fail('unexpected failure handler invoked!');
    +            console.error(err);
    +        }).done(done);
    +    });
    +
    +    it('should first remove platforms already in config.xml', function (done) {
    --- End diff --
    
    I think you forgot to update the description here when you copied the first test :)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-lib pull request #579: CB-12361 : added tests for save.js

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-lib/pull/579


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-lib pull request #579: CB-12361 : added tests for save.js

Posted by stevengill <gi...@git.apache.org>.
Github user stevengill commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/579#discussion_r129981636
  
    --- Diff: spec/cordova/platform/save.spec.js ---
    @@ -0,0 +1,71 @@
    +/**
    +    Licensed to the Apache Software Foundation (ASF) under one
    +    or more contributor license agreements.  See the NOTICE file
    +    distributed with this work for additional information
    +    regarding copyright ownership.  The ASF licenses this file
    +    to you under the Apache License, Version 2.0 (the
    +    "License"); you may not use this file except in compliance
    +    with the License.  You may obtain a copy of the License at
    +    http://www.apache.org/licenses/LICENSE-2.0
    +    Unless required by applicable law or agreed to in writing,
    +    software distributed under the License is distributed on an
    +    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +    KIND, either express or implied.  See the License for the
    +    specific language governing permissions and limitations
    +    under the License.
    +*/
    +
    +var Q = require('q');
    +var rewire = require('rewire');
    +var platform_save = rewire('../../../src/cordova/platform/save');
    +var platform_metadata = require('../../../src/cordova/platform_metadata');
    +var fail;
    +var semver = require('semver');
    +
    +describe('cordova/platform/save', function () {
    +    var hooks_mock;
    +    var projectRoot = '/some/path';
    +    var cfg_parser_mock = function () {};
    +    var cfg_parser_revert_mock;
    +
    +    beforeEach(function () {
    +        spyOn(semver, 'valid');
    +        cfg_parser_mock.prototype = jasmine.createSpyObj('config parser mock', ['write', 'removeEngine', 'addEngine','getEngines']);
    +        cfg_parser_revert_mock = platform_save.__set__('ConfigParser', cfg_parser_mock);
    +        cfg_parser_mock.prototype.getEngines.and.returnValue(['android']);
    +    });
    +
    +    afterEach(function () {
    +        cfg_parser_revert_mock();
    +    });
    +
    +    it('should first remove platforms already in config.xml', function (done) {
    +        platform_save(hooks_mock, projectRoot, {save : true})
    +        .then(function(res){
    +            expect(cfg_parser_mock.prototype.getEngines).toHaveBeenCalled();
    +            expect(cfg_parser_mock.prototype.removeEngine).toHaveBeenCalled();
    +        }).fail(function (err) {
    +            fail('unexpected failure handler invoked!');
    +            console.error(err);
    +        }).done(done);
    +    });
    +
    +    it('add and write to config.xml', function (done) {
    +        spyOn(platform_metadata, 'getPlatformVersions').and.returnValue(Q(['6.3.0']));
    --- End diff --
    
    so getPlatformVersions returns in the format of `{platform: platform, version: version}`. So instead of returning `Q([6.3.0])`, you could return `Q({platform: 'android', version: 6.3.0})`. That way the first argument for line 58 won't be undefined. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org