You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/09/23 00:16:27 UTC

[35/50] [abbrv] 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/cb-7219
Commit: ace7e33531e3dce2ac84038ca4c76fb4cfc4657f
Parents: 37f8ef3
Author: Suraj Pindoria <su...@yahoo.com>
Authored: Thu Sep 11 15:23:44 2014 -0700
Committer: Suraj Pindoria <su...@yahoo.com>
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'));
+            });
+        });
+    });
+});