[Pkg-javascript-commits] [node-coveralls] 78/332: added full test coverage on fetchGitData
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Nov 9 13:53:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-coveralls.
commit ecb13e11c3d7dd29552e5872329d8d0ea4a18fde
Author: Gabe Hayes <gabriel.hayes at gmail.com>
Date: Mon Jul 29 10:47:56 2013 -0700
added full test coverage on fetchGitData
---
lib/fetchGitData.js | 8 +----
test/fetchGitData.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 94 insertions(+), 8 deletions(-)
diff --git a/lib/fetchGitData.js b/lib/fetchGitData.js
index d79a3db..6ab0209 100644
--- a/lib/fetchGitData.js
+++ b/lib/fetchGitData.js
@@ -55,9 +55,6 @@ var fetchGitData = function(git) {
}
//-- Set required properties of git if they weren"t provided
- if (!git.hasOwnProperty("head")) {
- git.head = {};
- }
if (!git.hasOwnProperty("branch")) {
git.branch = "";
}
@@ -66,13 +63,10 @@ var fetchGitData = function(git) {
}
//-- Assert the property types
- if ("object" !== typeof git.head) {
- git.head = {};
- }
if ("string" !== typeof git.branch) {
git.branch = "";
}
- if (!git.remotes.hasOwnProperty("length")) {
+ if (!(git.remotes instanceof Array)) {
git.remotes = [];
}
diff --git a/test/fetchGitData.js b/test/fetchGitData.js
index aa5e2b2..c8ddbc5 100644
--- a/test/fetchGitData.js
+++ b/test/fetchGitData.js
@@ -77,7 +77,73 @@ describe("fetchGitData", function(){
]
});
});
- it("execute git commands when a valid commit hash is given", function() {
+ it("should convert git.branch to a string", function() {
+ var objectToString = git({
+ "head": {
+ "id": "COMMIT_HASH"
+ },
+ "branch": {
+ "covert": "to a string"
+ }
+ });
+ var arrayToString = git({
+ "head": {
+ "id": "COMMIT_HASH"
+ },
+ "branch": ["convert", "to", "a", "string"]
+ });
+ objectToString.branch.should.be.a("string");
+ arrayToString.branch.should.be.a("string");
+ });
+ it("should convert git.remotes to an array", function() {
+ var stringToArray = git({
+ "head": {
+ "id": "COMMIT_HASH"
+ },
+ "remotes": "convert from string to an array"
+ });
+ var objectToArray = git({
+ "head": {
+ "id": "COMMIT_HASH"
+ },
+ "remotes": {
+ "convert": "from object to an array"
+ }
+ });
+ stringToArray.remotes.should.be.instanceof(Array);
+ objectToArray.remotes.should.be.instanceof(Array);
+ });
+ it("should save passed remotes", function() {
+ var options = git({
+ "head": {
+ "id": "COMMIT_HASH"
+ },
+ "remotes": [
+ {
+ "name": "test",
+ "url": "https://my.test.url"
+ }
+ ]
+ });
+ options.should.eql({
+ "head": {
+ "id": "COMMIT_HASH",
+ "author_name": "Unknown Author",
+ "author_email": "",
+ "committer_name": "Unknown Committer",
+ "committer_email": "",
+ "message": "Unknown Commit Message"
+ },
+ "branch": "",
+ "remotes": [
+ {
+ "name": "test",
+ "url": "https://my.test.url"
+ }
+ ]
+ });
+ });
+ it("should execute git commands when a valid commit hash is given", function() {
var options = git({
"head": {
"id": "5eaec7e76af0743f9764e617472ef434f283a195"
@@ -96,4 +162,30 @@ describe("fetchGitData", function(){
options.remotes.should.be.instanceof(Array);
options.remotes.length.should.be.above(0);
});
+ it("should combine passed remotes with git remotes when a valid commit hash is given", function() {
+ var options = git({
+ "head": {
+ "id": "5eaec7e76af0743f9764e617472ef434f283a195"
+ },
+ "remotes": [
+ {
+ "name": "test",
+ "url": "https://my.test.url"
+ }
+ ]
+ });
+ options.head.should.eql({
+ "id": "5eaec7e76af0743f9764e617472ef434f283a195",
+ "author_name": "cainus",
+ "author_email": "gregg at caines.ca",
+ "committer_name": "cainus",
+ "committer_email": "gregg at caines.ca",
+ "message": "first commit"
+ });
+ options.branch.should.equal("master");
+ options.remotes.should.includeEql({
+ "name": "test",
+ "url": "https://my.test.url"
+ });
+ });
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git
More information about the Pkg-javascript-commits
mailing list