You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/08/11 18:21:53 UTC

cordova-lib git commit: CB-12361 : added tests for list platform

Repository: cordova-lib
Updated Branches:
  refs/heads/master f399c739b -> 9cdc0f2b1


CB-12361 : added tests for list 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/9cdc0f2b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/9cdc0f2b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/9cdc0f2b

Branch: refs/heads/master
Commit: 9cdc0f2b1af7663a3db2659ef279d97164f8991a
Parents: f399c73
Author: Audrey So <au...@apache.org>
Authored: Mon Jul 17 16:06:37 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Fri Aug 11 10:50:40 2017 -0700

----------------------------------------------------------------------
 spec/cordova/platform/list.spec.js | 74 +++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9cdc0f2b/spec/cordova/platform/list.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/platform/list.spec.js b/spec/cordova/platform/list.spec.js
new file mode 100644
index 0000000..48c17f9
--- /dev/null
+++ b/spec/cordova/platform/list.spec.js
@@ -0,0 +1,74 @@
+/**
+    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 platform_list = require('../../../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 fire 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) {
+                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) {
+                fail('unexpected failure handler invoked!');
+                console.error(err);
+            }).done(done);
+    });
+
+    it('should return platform list', function (done) {
+        var platformList = ['android', 'ios'];
+        expect(platform_list.addDeprecatedInformationToPlatforms(platformList).toString()).toBe('android,ios');
+        done();
+    });
+
+    it('should return deprecated platform information', function (done) {
+        var platformList = ['blackberry10'];
+        expect(platform_list.addDeprecatedInformationToPlatforms(platformList).toString()).toBe('blackberry10 (deprecated)');
+        done();
+    });
+});


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org