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 66A86200B5C for ; Thu, 28 Jul 2016 01:29:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6589E160A93; Wed, 27 Jul 2016 23:29:05 +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 B95F5160A90 for ; Thu, 28 Jul 2016 01:29:04 +0200 (CEST) Received: (qmail 8783 invoked by uid 500); 27 Jul 2016 23:29:03 -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 8772 invoked by uid 99); 27 Jul 2016 23:29:03 -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; Wed, 27 Jul 2016 23:29:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5EA6DE02A2; Wed, 27 Jul 2016 23:29:03 +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 #467: CB-9825: tests for cocoapod integration for p... Content-Type: text/plain Message-Id: <20160727232903.5EA6DE02A2@git1-us-west.apache.org> Date: Wed, 27 Jul 2016 23:29:03 +0000 (UTC) archived-at: Wed, 27 Jul 2016 23:29:05 -0000 Github user stevengill commented on a diff in the pull request: https://github.com/apache/cordova-lib/pull/467#discussion_r72542674 --- Diff: cordova-lib/spec-cordova/platform.spec.js --- @@ -356,3 +356,123 @@ describe('plugin add and rm end-to-end --fetch', function () { .fin(done); }, 60000); }); + +describe('cocoapod plugin add and rm end-to-end', function () { + + var tmpDir = helpers.tmpDir('cocoapod_plugin_test'); + var project = path.join(tmpDir, 'hello4'); + + var samplePlugin = path.resolve('./spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent'); + var overlappingDependencyPlugin = path.resolve('./spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency'); + var AFNetworking = 'AFNetworking', + CWStatusBarNotification = 'CWStatusBarNotification'; + var podfile, podsJSON, workspace; + + beforeEach(function() { + shell.exec('pwd'); + process.chdir(tmpDir); + }); + + afterEach(function() { + process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows. + shell.rm('-rf', tmpDir); + }); + + it('installs and uninstalls plugin depending on new pod and existing pod', function(done) { + + cordova.raw.create('hello4') + .then(function() { + process.chdir(project); + //TODO: change this to cordova-ios on npm + return cordova.raw.platform('add', 'https://github.com/juliascript/cordova-ios.git#CB-9825'); + }) + .then(function() { + return cordova.raw.plugin('add', samplePlugin); + }) + .then(function() { + podfile = path.resolve('./platforms/ios/Podfile'); + podsJSON = path.resolve('./platforms/ios/pods.json'); + workspace = path.resolve('./platforms/ios/HelloCordova.xcworkspace'); + + //podfile should have been created + fs.exists(podfile, function(podfileExists){ + expect(podfileExists); + }); + + //pods.json should have been created + fs.exists(podsJSON, function(podsJSONExists){ + expect(podsJSONExists); + }); + + //workspace should have been created + fs.exists(workspace, function(workspaceCreated){ + expect(workspaceCreated); + }); + + delete require.cache[require.resolve(podfile)]; + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + + expect(podfileContent.includes(AFNetworking)); + + delete require.cache[require.resolve(podsJSON)]; + var podsJSONContent = require(podsJSON); + + expect(podsJSONContent[AFNetworking] !== null); + return cordova.raw.plugin('add', overlappingDependencyPlugin); + }) + .then(function() { + delete require.cache[require.resolve(podfile)]; + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + var numberOfTimesAFNetworkingIsInPodfile = podfileContent.match(/AFNetworking/g || []).length; + + expect(podfileContent.includes(CWStatusBarNotification)); + expect(numberOfTimesAFNetworkingIsInPodfile).toEqual(1); + + delete require.cache[require.resolve(podsJSON)]; + var podsJSONContent = require(podsJSON); + var countPropertyOfAFNetworkingInPodsJSON = podsJSONContent[AFNetworking].count; + var specPropertyOfAFNetworkingInPodsJSON = podsJSONContent[AFNetworking].spec; + + expect(countPropertyOfAFNetworkingInPodsJSON).toEqual(2); + //spec property should not be changed because of overlapping dependency + expect(specPropertyOfAFNetworkingInPodsJSON).toEqual('~> 3.0'); + + return cordova.raw.plugin('rm','sample-cocoapod-plugin-overlapping-dependency'); + }) + .then(function() { + //expect only AFNetworking + delete require.cache[require.resolve(podfile)]; + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + + expect(podfileContent.includes(CWStatusBarNotification)).toBe(false); + expect(podfileContent.includes(AFNetworking)); + + delete require.cache[require.resolve(podsJSON)]; + var podsJSONContent = require(podsJSON); + + expect(podsJSONContent[AFNetworking]); + expect(podsJSONContent[CWStatusBarNotification] === undefined); + + return cordova.raw.plugin('rm', 'sample-cordova-plugin-cocoapod-dependent'); + }) + .then(function() { + //expect no pods + delete require.cache[require.resolve(podfile)]; --- End diff -- yeah, the cache delete is only required for pods.json. Not podfile :) --- 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