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/17 21:38:59 UTC

[GitHub] cordova-lib pull request #576: CB-12361 : added unit tests for remove platfo...

GitHub user audreyso opened a pull request:

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

    CB-12361 : added unit tests for remove platform

    <!--
    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?
    Added unit tests for remove platform
    
    ### What testing has been done on this change?
    
    
    ### 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-7

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

    https://github.com/apache/cordova-lib/pull/576.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 #576
    
----
commit 61ddb3d78182c51937539bcb8728fe97f9a9259f
Author: Audrey So <au...@apache.org>
Date:   2017-07-17T19:01:20Z

    CB-12361 : added tests for remove platform

----


---
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 #576: CB-12361 : added unit tests for remove platfo...

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/576#discussion_r129713116
  
    --- Diff: spec/cordova/platform/remove.spec.js ---
    @@ -0,0 +1,160 @@
    +/**
    +    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 path = require('path');
    +var fs = require('fs');
    +var Q = require('q');
    +var events = require('cordova-common').events;
    +var rewire = require('rewire');
    +var platform_remove = rewire('../../../src/cordova/platform/remove');
    +var platform_metadata = require('../../../src/cordova/platform_metadata');
    +var cordova_util = require('../../../src/cordova/util');
    +var promiseutil = require('../../../src/util/promise-util');
    +var fail;
    +
    +describe('cordova/platform/remove', function () {
    +    var projectRoot = '/some/path';
    +    var cfg_parser_mock = function () {};
    +    var cfg_parser_revert_mock;
    +    var hooks_mock;
    +    var package_json_mock;
    +    package_json_mock = jasmine.createSpyObj('package json mock', ['cordova', 'dependencies']);
    +    package_json_mock.dependencies = {};
    +    package_json_mock.cordova = {};
    +
    +    var hooksRunnerRevert;
    +
    +    beforeEach(function () {
    +        hooks_mock = jasmine.createSpyObj('hooksRunner mock', ['fire']);
    +        hooks_mock.fire.and.returnValue(Q());
    +        hooksRunnerRevert = platform_remove.__set__('HooksRunner', function () {});
    +        cfg_parser_mock.prototype = jasmine.createSpyObj('config parser mock', ['write', 'removeEngine']);
    +        cfg_parser_revert_mock = platform_remove.__set__('ConfigParser', cfg_parser_mock);
    +        spyOn(fs, 'existsSync').and.returnValue(false);
    +        spyOn(fs, 'writeFileSync');
    +        spyOn(cordova_util, 'removePlatformPluginsJson');
    +        spyOn(events, 'emit');
    +        spyOn(cordova_util, 'requireNoCache').and.returnValue({});
    +    });
    +    afterEach(function () {
    +        cfg_parser_revert_mock();
    +        hooksRunnerRevert();
    +    });
    +    describe('error/warning conditions', function () {
    +        it('should require specifying at least one platform', function (done) {
    +            platform_remove('remove', hooks_mock).then(function () {
    +                fail('remove success handler unexpectedly invoked');
    +            }).fail(function (e) {
    +                expect(e.message).toContain('No platform(s) specified.');
    +            }).done(done);
    +        });
    +    });
    +    describe('happy path (success conditions)', function () {
    +        it('should fire the before_platform_* hook', function () {
    --- End diff --
    
    for some reason, when i run this test I get `Parsing false failed`. But the test passes


---
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 #576: CB-12361 : added unit tests for remove platfo...

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

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


---
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 issue #576: CB-12361 : added unit tests for remove platform

Posted by audreyso <gi...@git.apache.org>.
Github user audreyso commented on the issue:

    https://github.com/apache/cordova-lib/pull/576
  
    Thanks @stevengill I will merge it!


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