Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 97B0D11459 for ; Mon, 15 Sep 2014 22:59:53 +0000 (UTC) Received: (qmail 93035 invoked by uid 500); 15 Sep 2014 22:59:53 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 92948 invoked by uid 500); 15 Sep 2014 22:59:53 -0000 Mailing-List: contact commits-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 commits@cordova.apache.org Received: (qmail 92932 invoked by uid 99); 15 Sep 2014 22:59:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Sep 2014 22:59:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id F3403A14962; Mon, 15 Sep 2014 22:59:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anis@apache.org To: commits@cordova.apache.org Date: Mon, 15 Sep 2014 22:59:53 -0000 Message-Id: <1482560462b74ba88fd24f29f6ce4b6e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: Added tests for browser platform Added tests for browser platform Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/ace7e335 Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/ace7e335 Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/ace7e335 Branch: refs/heads/master Commit: ace7e33531e3dce2ac84038ca4c76fb4cfc4657f Parents: 37f8ef3 Author: Suraj Pindoria Authored: Thu Sep 11 15:23:44 2014 -0700 Committer: Suraj Pindoria Committed: Thu Sep 11 15:23:44 2014 -0700 ---------------------------------------------------------------------- .../metadata/browser_parser.spec.js | 88 ++++++++++++++++++++ 1 file changed, 88 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ace7e335/cordova-lib/spec-cordova/metadata/browser_parser.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/metadata/browser_parser.spec.js b/cordova-lib/spec-cordova/metadata/browser_parser.spec.js new file mode 100644 index 0000000..0da4f7f --- /dev/null +++ b/cordova-lib/spec-cordova/metadata/browser_parser.spec.js @@ -0,0 +1,88 @@ +/** + 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 platforms = require('../../src/cordova/platforms'), + util = require('../../src/cordova/util'), + path = require('path'), + shell = require('shelljs'), + fs = require('fs'); + +describe('browser project parser', function() { + var proj = path.join('some', 'path'); + var exists; + + beforeEach(function() { + exists = spyOn(fs, 'existsSync').andReturn(true); + }); + + describe('constructions', function() { + it('should create an instance with a path', function() { + expect(function() { + var p = new platforms.browser.parser(proj); + expect(p.path).toEqual(proj); + }).not.toThrow(); + }); + }); + + describe('instance', function() { + var p, cp, rm, mkdir, is_cordova; + var browser_proj = path.join(proj, 'platforms', 'browser'); + + beforeEach(function() { + p = new platforms.browser.parser(browser_proj); + cp = spyOn(shell, 'cp'); + rm = spyOn(shell, 'rm'); + mkdir = spyOn(shell, 'mkdir'); + is_cordova = spyOn(util, 'isCordova').andReturn(proj); + }); + + describe('www_dir method', function() { + it('should return /www', function() { + expect(p.www_dir()).toEqual(path.join(browser_proj, 'www')); + }); + }); + + describe('config_xml method', function() { + it('should return the location of config.xml', function() { + expect(p.config_xml()).toEqual(path.join(proj, 'platforms', 'browser', 'config.xml')); + }); + }); + + describe('update_www method', function() { + it('should rm project-level www and cp in platform agnostic www', function() { + p.update_www(); + expect(rm).toHaveBeenCalled(); + expect(cp).toHaveBeenCalled(); + }); + }); + + describe('update_overrides method', function() { + it('should do nothing if merges directory does not exist', function() { + exists.andReturn(false); + p.update_overrides(); + expect(cp).not.toHaveBeenCalled(); + }); + + it('should copy merges path into www', function() { + p.update_overrides(); + expect(cp).toHaveBeenCalledWith('-rf', path.join(proj, 'merges', 'browser', '*'), path.join(proj, 'platforms', 'browser', 'www')); + }); + }); + }); +});