mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
CB-5971: Add unit tests to cordova-android
This commit is contained in:
parent
ff260c03ca
commit
bb141a70e8
@ -288,3 +288,7 @@ exports.updateProject = function(projectPath) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// For testing
|
||||||
|
exports.validatePackageName = validatePackageName;
|
||||||
|
exports.validateProjectName = validateProjectName;
|
||||||
|
@ -12,10 +12,17 @@
|
|||||||
"cordova",
|
"cordova",
|
||||||
"apache"
|
"apache"
|
||||||
],
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "jasmine-node --color spec"
|
||||||
|
},
|
||||||
"author": "Apache Software Foundation",
|
"author": "Apache Software Foundation",
|
||||||
"license": "Apache version 2.0",
|
"license": "Apache version 2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"q": "^0.9.0",
|
"q": "^0.9.0",
|
||||||
"shelljs": "^0.2.6"
|
"shelljs": "^0.2.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"jasmine-node": "~1",
|
||||||
|
"promise-matchers": "~0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
82
spec/create.spec.js
Normal file
82
spec/create.spec.js
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
/* jshint laxcomma:true */
|
||||||
|
|
||||||
|
require("promise-matchers");
|
||||||
|
|
||||||
|
var create = require("../bin/lib/create");
|
||||||
|
|
||||||
|
describe("create", function () {
|
||||||
|
describe("validatePackageName", function() {
|
||||||
|
var valid = [
|
||||||
|
"org.apache.mobilespec"
|
||||||
|
, "com.example"
|
||||||
|
, "com.42floors.package"
|
||||||
|
];
|
||||||
|
var invalid = [
|
||||||
|
""
|
||||||
|
, "com.class.is.bad"
|
||||||
|
, "0com.example.mobilespec"
|
||||||
|
, "c-m.e@a!p%e.mobilespec"
|
||||||
|
, "notenoughdots"
|
||||||
|
, ".starts.with.a.dot"
|
||||||
|
, "ends.with.a.dot."
|
||||||
|
, "_underscore.anything"
|
||||||
|
, "underscore._something"
|
||||||
|
, "_underscore._all._the._things"
|
||||||
|
];
|
||||||
|
|
||||||
|
valid.forEach(function(package_name) {
|
||||||
|
it("should accept " + package_name, function(done) {
|
||||||
|
expect(create.validatePackageName(package_name)).toHaveBeenResolved(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
invalid.forEach(function(package_name) {
|
||||||
|
it("should reject " + package_name, function(done) {
|
||||||
|
expect(create.validatePackageName(package_name)).toHaveBeenRejected(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("validateProjectName", function() {
|
||||||
|
var valid = [
|
||||||
|
"mobilespec"
|
||||||
|
, "package_name"
|
||||||
|
, "PackageName"
|
||||||
|
, "CordovaLib"
|
||||||
|
];
|
||||||
|
var invalid = [
|
||||||
|
""
|
||||||
|
, "0startswithdigit"
|
||||||
|
, "CordovaActivity"
|
||||||
|
];
|
||||||
|
|
||||||
|
valid.forEach(function(project_name) {
|
||||||
|
it("should accept " + project_name, function(done) {
|
||||||
|
expect(create.validateProjectName(project_name)).toHaveBeenResolved(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
invalid.forEach(function(project_name) {
|
||||||
|
it("should reject " + project_name, function(done) {
|
||||||
|
expect(create.validateProjectName(project_name)).toHaveBeenRejected(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user