cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agrieve <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: CB-8239 Add support for git urls to 'cor...
Date Sun, 18 Jan 2015 02:00:56 GMT
Github user agrieve commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/148#discussion_r23130176
  
    --- Diff: cordova-lib/spec-cordova/util.spec.js ---
    @@ -183,4 +184,138 @@ describe('util module', function() {
                 expect(res.indexOf('CVS')).toEqual(-1);
             });
         });
    +    describe('getPlatformDetailsFromDir function', function () {
    +
    +        var dir = 'C:\\Projects\\cordova-projects\\cordova-android';
    +        var getPackageJsonContentOriginal = util.__get__('getPackageJsonContent');
    +        var resolvePathOriginal = util.__get__('resolvePath');
    +        var getPlatformDetailsFromDir = util.__get__('getPlatformDetailsFromDir'); //
function under test
    +
    +        beforeEach(function () {
    +            util.__set__('getPackageJsonContent', function (p) {
    +                return p + '\\package';
    +            });
    +            util.__set__('resolvePath', function (p) {
    +                return p;
    +            });
    +        });
    +
    +        afterEach(function () {
    +            util.__set__('getPackageJsonContent', getPackageJsonContentOriginal);
    +            util.__set__('resolvePath', resolvePathOriginal);
    +        });
    +
    +        it('returns the appropriate platform details', function (done) {
    +
    +            // Mock out package.json content
    +            util.__set__('getPackageJsonContent', function (p) {
    +                return {
    +                    'name': 'cordova-android',
    +                    'version': '3.7.0-dev',
    +                    'description': 'cordova-android release',
    +                    'main': 'bin/create'
    +                };
    +            });
    +
    +            getPlatformDetailsFromDir(dir).then(function (platformDetails) {
    +                expect(platformDetails.platform).toBe('android');
    +                expect(platformDetails.libDir).toBe(dir);
    +                done();
    +            });
    +        });
    +
    +        it('throws if the directory supplied does not contain a package.json file', function
(done) {
    +
    +            util.__set__('getPackageJsonContent', function (p) {
    --- End diff --
    
    Better to use Jasmine's spyOn(util, 'getPackageJsonContent'), since jasmine will take
care of restoring the original function after each spec


---
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


Mime
View raw message