Skip to content

Commit

Permalink
Merge pull request #1422 from rcjsuen/commit-tests
Browse files Browse the repository at this point in the history
Add two missing tests to Commit
  • Loading branch information
cjhoward92 committed Jan 22, 2018
2 parents 86939c1 + f883e1d commit beaa78d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/tests/commit.js
Expand Up @@ -13,7 +13,9 @@ var exec = require("../../utils/execPromise");
describe("Commit", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
var Commit = NodeGit.Commit;
var Diff = NodeGit.Diff;
var Oid = NodeGit.Oid;

var reposPath = local("../repos/workdir");
var oid = "fce88902e66c72b5b93e75bdb5ae717038b221f6";
Expand Down Expand Up @@ -604,6 +606,31 @@ describe("Commit", function() {
});
});

it("can lookup using a short id", function () {
return NodeGit.Repository.open(reposPath)
.then(function (repo) {
return Commit.lookupPrefix(repo, Oid.fromString("bf1da765"), 8);
})
.then(function (commit) {
assert.equal(commit.id().toString(),
"bf1da765e357a9b936d6d511f2c7b78e0de53632");
});
});

it("can find nth gen ancestor", function () {
return NodeGit.Repository.open(reposPath)
.then(function (repo) {
return repo.getCommit("b52067acaa755c3b3fc21b484ffed2bce4150f62");
})
.then(function (commit) {
return commit.nthGenAncestor(3);
})
.then(function (commit) {
assert.equal(commit.id().toString(),
"9b2f3a37d46d47248d2704b6a46ec7e197bcd48c");
});
});

describe("Commit's Author", function() {
before(function() {
this.author = this.commit.author();
Expand Down

0 comments on commit beaa78d

Please sign in to comment.