cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kerrishotts <>
Subject [GitHub] cordova-lib pull request #562: Removing lazy load, platform command refactor...
Date Thu, 15 Jun 2017 15:29:51 GMT
Github user kerrishotts commented on a diff in the pull request:
    --- Diff: spec-cordova/platform/index.spec.js ---
    @@ -0,0 +1,181 @@
    +    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
    +    Unless required by applicable law or agreed to in writing,
    +    software distributed under the License is distributed on an
    +    KIND, either express or implied.  See the License for the
    +    specific language governing permissions and limitations
    +    under the License.
    +/* eslint-env jasmine */
    +var rewire = require('rewire');
    +var platform = rewire('../../src/cordova/platform');
    +var cordova_util = require('../../src/cordova/util');
    +describe('cordova/platform', function () {
    +    var hooksRunnerRevert;
    +    var projectRoot = 'somepath';
    +    beforeEach(function () {
    +        // TODO: if we can change HooksRunner from a prototypal class to a function or
    +        // we could eliminate the need for rewire here and use just jasmine spies.
    +        hooksRunnerRevert = platform.__set__('HooksRunner', function () {});
    +        spyOn(cordova_util, 'cdProjectRoot').and.returnValue(projectRoot);
    +    });
    +    afterEach(function () {
    +        hooksRunnerRevert();
    +    });
    +    describe('main module function', function () {
    +        describe('error/warning conditions', function () {
    +            // TODO: what about other commands? update? save?
    +            it('should require at least one platform for add and remove commands', function
(done) {
    +                // targets = empty array
    +                platform('add', []).then(function () {
    +                    fail('should not succeed without targets');
    +                }, function (err) {
    +                    expect(err).toMatch(/You need to qualify.* with one or more platforms/gi);
    --- End diff --
    Out of scope for this commit, but I'd love to see the ability to use `expect(err).toBeInstanceOf(CordovaErrors.ExpectedOneOrMorePlatforms)`.
That way should the error message ever change, the test still passes. Plus, then we don't
have to worry about ignoring dynamic portions of the error.
    I have no idea how big a job that might be (I expect it'd be pretty big!), so I'm just
throwing it out there as a "nice-to-have", but I wouldn't want it to hold up any progress
on this commit, which is super important.
    Thanks for your hard work on this, BTW! 

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message