[GitHub] cordova-lib pull request #578: CB-12361 : added unit-tests for getPlatformDe...

2017-07-28 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/cordova-lib/pull/578


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-lib pull request #578: CB-12361 : added unit-tests for getPlatformDe...

2017-07-27 Thread stevengill
Github user stevengill commented on a diff in the pull request:

https://github.com/apache/cordova-lib/pull/578#discussion_r129996355
  
--- Diff: spec/cordova/platform/getPlatformDetailsFromDir.spec.js ---
@@ -0,0 +1,79 @@
+/**
+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 path = require('path');
+var fs = require('fs');
+var Q = require('q');
+var rewire = require('rewire');
+var cordova_util = require('../../../src/cordova/util');
+var platform_getPlatformDetails = 
rewire('../../../src/cordova/platform/getPlatformDetailsFromDir');
+var events = require('cordova-common').events;
+var fail;
+
+describe('cordova/platform/getPlatformDetailsFromDir', function () {
+var package_json_mock;
+package_json_mock = jasmine.createSpyObj('package json mock', 
['cordova', 'dependencies']);
+package_json_mock.name = 'io.cordova.hellocordova';
+package_json_mock.version = '1.0.0';
+
+beforeEach(function () {
+spyOn(Q, 'reject');
+spyOn(fs, 'existsSync');
+spyOn(cordova_util, 'requireNoCache');
+spyOn(events, 'emit');
+});
+
+it('should throw if no config.xml or pkgJson', function (done) {
+platform_getPlatformDetails('dir', ['ios']);
+expect(Q.reject).toHaveBeenCalledWith(jasmine.stringMatching(/does 
not seem to contain a valid package.json or a valid Cordova platform/));
+done();
+});
+
+it('should throw if no platform is provided', function (done) {
+cordova_util.requireNoCache.and.returnValue({});
+platform_getPlatformDetails('dir');
+expect(Q.reject).toHaveBeenCalledWith(jasmine.stringMatching(/does 
not seem to contain a Cordova platform:/));
+done();
+});
+
+it('should return a promise with platform and version', function 
(done) {
+fs.existsSync.and.callFake(function(filePath) {
+if(path.basename(filePath) === 'package.json') {
+return true;
+} else {
+return false;
+}
+});
+cordova_util.requireNoCache.and.returnValue(package_json_mock);
+platform_getPlatformDetails('dir', ['cordova-android'])
+.then(function(result) {
+expect(result.platform).toBe('io.cordova.hellocordova');
+expect(result.version).toBe('1.0.0');
+expect(Q.reject).not.toHaveBeenCalled();
+}).fail(function (err) {
+fail('unexpected failure handler invoked!');
+console.error(err);
+}).done(done);
+});
+
+it('should remove the cordova- prefix from the platform name for known 
platforms', function (done) {
+platform_getPlatformDetails.platformFromName('cordova-ios');
+expect(events.emit).toHaveBeenCalledWith('verbose', 
jasmine.stringMatching(/Removing "cordova-" prefix/));
+
expect(platform_getPlatformDetails.platformFromName('cordova-ios')).toBe('ios');
--- End diff --

yup


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-lib pull request #578: CB-12361 : added unit-tests for getPlatformDe...

2017-07-27 Thread audreyso
Github user audreyso commented on a diff in the pull request:

https://github.com/apache/cordova-lib/pull/578#discussion_r129969368
  
--- Diff: spec/cordova/platform/getPlatformDetailsFromDir.spec.js ---
@@ -0,0 +1,79 @@
+/**
+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 path = require('path');
+var fs = require('fs');
+var Q = require('q');
+var rewire = require('rewire');
+var cordova_util = require('../../../src/cordova/util');
+var platform_getPlatformDetails = 
rewire('../../../src/cordova/platform/getPlatformDetailsFromDir');
+var events = require('cordova-common').events;
+var fail;
+
+describe('cordova/platform/getPlatformDetailsFromDir', function () {
+var package_json_mock;
+package_json_mock = jasmine.createSpyObj('package json mock', 
['cordova', 'dependencies']);
+package_json_mock.name = 'io.cordova.hellocordova';
+package_json_mock.version = '1.0.0';
+
+beforeEach(function () {
+spyOn(Q, 'reject');
+spyOn(fs, 'existsSync');
+spyOn(cordova_util, 'requireNoCache');
+spyOn(events, 'emit');
+});
+
+it('should throw if no config.xml or pkgJson', function (done) {
+platform_getPlatformDetails('dir', ['ios']);
+expect(Q.reject).toHaveBeenCalledWith(jasmine.stringMatching(/does 
not seem to contain a valid package.json or a valid Cordova platform/));
+done();
+});
+
+it('should throw if no platform is provided', function (done) {
+cordova_util.requireNoCache.and.returnValue({});
+platform_getPlatformDetails('dir');
+expect(Q.reject).toHaveBeenCalledWith(jasmine.stringMatching(/does 
not seem to contain a Cordova platform:/));
+done();
+});
+
+it('should return a promise with platform and version', function 
(done) {
+fs.existsSync.and.callFake(function(filePath) {
+if(path.basename(filePath) === 'package.json') {
+return true;
+} else {
+return false;
+}
+});
+cordova_util.requireNoCache.and.returnValue(package_json_mock);
+platform_getPlatformDetails('dir', ['cordova-android'])
+.then(function(result) {
+expect(result.platform).toBe('io.cordova.hellocordova');
+expect(result.version).toBe('1.0.0');
+expect(Q.reject).not.toHaveBeenCalled();
+}).fail(function (err) {
+fail('unexpected failure handler invoked!');
+console.error(err);
+}).done(done);
+});
+
+it('should remove the cordova- prefix from the platform name for known 
platforms', function (done) {
+platform_getPlatformDetails.platformFromName('cordova-ios');
+expect(events.emit).toHaveBeenCalledWith('verbose', 
jasmine.stringMatching(/Removing "cordova-" prefix/));
+
expect(platform_getPlatformDetails.platformFromName('cordova-ios')).toBe('ios');
--- End diff --

ohh okay do you mean just like this?

```
 it('should remove the cordova- prefix from the platform name for known 
platforms', function (done) {

expect(platform_getPlatformDetails.platformFromName('cordova-ios')).toBe('ios');
expect(events.emit).toHaveBeenCalledWith('verbose', 
jasmine.stringMatching(/Removing "cordova-" prefix/));
done();
});
```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-lib pull request #578: CB-12361 : added unit-tests for getPlatformDe...

2017-07-27 Thread stevengill
Github user stevengill commented on a diff in the pull request:

https://github.com/apache/cordova-lib/pull/578#discussion_r129926425
  
--- Diff: spec/cordova/platform/getPlatformDetailsFromDir.spec.js ---
@@ -0,0 +1,79 @@
+/**
+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 path = require('path');
+var fs = require('fs');
+var Q = require('q');
+var rewire = require('rewire');
+var cordova_util = require('../../../src/cordova/util');
+var platform_getPlatformDetails = 
rewire('../../../src/cordova/platform/getPlatformDetailsFromDir');
+var events = require('cordova-common').events;
+var fail;
+
+describe('cordova/platform/getPlatformDetailsFromDir', function () {
+var package_json_mock;
+package_json_mock = jasmine.createSpyObj('package json mock', 
['cordova', 'dependencies']);
+package_json_mock.name = 'io.cordova.hellocordova';
+package_json_mock.version = '1.0.0';
+
+beforeEach(function () {
+spyOn(Q, 'reject');
+spyOn(fs, 'existsSync');
+spyOn(cordova_util, 'requireNoCache');
+spyOn(events, 'emit');
+});
+
+it('should throw if no config.xml or pkgJson', function (done) {
+platform_getPlatformDetails('dir', ['ios']);
+expect(Q.reject).toHaveBeenCalledWith(jasmine.stringMatching(/does 
not seem to contain a valid package.json or a valid Cordova platform/));
+done();
+});
+
+it('should throw if no platform is provided', function (done) {
+cordova_util.requireNoCache.and.returnValue({});
+platform_getPlatformDetails('dir');
+expect(Q.reject).toHaveBeenCalledWith(jasmine.stringMatching(/does 
not seem to contain a Cordova platform:/));
+done();
+});
+
+it('should return a promise with platform and version', function 
(done) {
+fs.existsSync.and.callFake(function(filePath) {
+if(path.basename(filePath) === 'package.json') {
+return true;
+} else {
+return false;
+}
+});
+cordova_util.requireNoCache.and.returnValue(package_json_mock);
+platform_getPlatformDetails('dir', ['cordova-android'])
+.then(function(result) {
+expect(result.platform).toBe('io.cordova.hellocordova');
+expect(result.version).toBe('1.0.0');
+expect(Q.reject).not.toHaveBeenCalled();
+}).fail(function (err) {
+fail('unexpected failure handler invoked!');
+console.error(err);
+}).done(done);
+});
+
+it('should remove the cordova- prefix from the platform name for known 
platforms', function (done) {
+platform_getPlatformDetails.platformFromName('cordova-ios');
+expect(events.emit).toHaveBeenCalledWith('verbose', 
jasmine.stringMatching(/Removing "cordova-" prefix/));
+
expect(platform_getPlatformDetails.platformFromName('cordova-ios')).toBe('ios');
--- End diff --

You can take the expect from line 76 and combine it with line 74 and delete 
76. So line 74 gets replaced by line 76. Line 75 should still pass


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-lib pull request #578: CB-12361 : added unit-tests for getPlatformDe...

2017-07-18 Thread audreyso
GitHub user audreyso opened a pull request:

https://github.com/apache/cordova-lib/pull/578

CB-12361 : added unit-tests for getPlatformDetailsFromDir



### Platforms affected


### What does this PR do?

added unit-tests for getPlatformDetailsFromDir

### What testing has been done on this change?


### Checklist
- [X] [Reported an issue](http://cordova.apache.org/contribute/issues.html) 
in the JIRA database
- [X] Commit message follows the format: "CB-3232: (android) Fix bug with 
resolving file paths", where CB- is the JIRA ID & "android" is the platform 
affected.
- [X] Added automated test coverage as appropriate for this change.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/audreyso/cordova-lib CB-12361-10

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cordova-lib/pull/578.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #578


commit e8a1cf2c062fd735ffb767dcd1c249de5c35684d
Author: Audrey So 
Date:   2017-07-18T17:35:28Z

CB-12361 : added unit-tests for getPlatformDetailsFromDir




---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org