Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 12609200CE0 for ; Thu, 27 Jul 2017 02:43:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 10DA1169DD1; Thu, 27 Jul 2017 00:43:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 56A13169DCB for ; Thu, 27 Jul 2017 02:43:07 +0200 (CEST) Received: (qmail 67060 invoked by uid 500); 27 Jul 2017 00:43:06 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 67049 invoked by uid 99); 27 Jul 2017 00:43:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jul 2017 00:43:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BF5F4E9456; Thu, 27 Jul 2017 00:43:05 +0000 (UTC) From: stevengill To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-lib pull request #577: CB-12361 : added tests for platform/list.js Content-Type: text/plain Message-Id: <20170727004305.BF5F4E9456@git1-us-west.apache.org> Date: Thu, 27 Jul 2017 00:43:05 +0000 (UTC) archived-at: Thu, 27 Jul 2017 00:43:08 -0000 Github user stevengill commented on a diff in the pull request: https://github.com/apache/cordova-lib/pull/577#discussion_r129730654 --- Diff: spec/cordova/platform/list.spec.js --- @@ -0,0 +1,66 @@ +/** + 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 events = require('cordova-common').events; +var Q = require('q'); +var events = require('cordova-common').events; +var rewire = require('rewire'); +var platform_list = rewire('../../../src/cordova/platform/list'); +var platform_metadata = require('../../../src/cordova/platform_metadata'); +var cordova_util = require('../../../src/cordova/util'); +var fail; + +describe('cordova/platform/list', function () { + var hooks_mock; + var projectRoot = '/some/path'; + + beforeEach(function () { + hooks_mock = jasmine.createSpyObj('hooksRunner mock', ['fire']); + hooks_mock.fire.and.returnValue(Q()); + spyOn(cordova_util, 'getInstalledPlatformsWithVersions').and.callThrough(); + spyOn(events, 'emit'); + spyOn(platform_metadata, 'save'); + spyOn(cordova_util, 'requireNoCache').and.returnValue({}); + }); + + it('should fire the before_platform_ls hook', function () { + platform_list(hooks_mock, projectRoot, {save : true}); + expect(hooks_mock.fire).toHaveBeenCalledWith('before_platform_ls', Object({ save: true })); + }); + + it('should file the after_platform_ls hook',function (done) { + platform_list(hooks_mock, projectRoot, {save : true}) + .then(function(result) { + expect(hooks_mock.fire).toHaveBeenCalledWith('after_platform_ls', Object({ save: true })); + }).fail(function (err) { + console.log(err.message); + fail('unexpected failure handler invoked!'); + console.error(err); + }).done(done); + }); + + it('should print results of available platforms',function (done) { + platform_list(hooks_mock, projectRoot, {save : true}) + .then(function(result) { + expect(events.emit).toHaveBeenCalledWith('results', jasmine.stringMatching(/Installed platforms:/)); + }).fail(function (err) { + console.log(err.message); --- End diff -- I don't think your fail function should `console.log(err.message)` and `console.log(err)`. Just `console.log(err)` is sufficient. --- 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