Skip to content

Commit

Permalink
Merge 6318739 into 6cf888f
Browse files Browse the repository at this point in the history
  • Loading branch information
vanadium23 committed May 29, 2015
2 parents 6cf888f + 6318739 commit ae74dfb
Showing 1 changed file with 68 additions and 11 deletions.
79 changes: 68 additions & 11 deletions test/tests/status_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,80 @@ describe("StatusFile", function() {
var StatusFile = NodeGit.StatusFile;

var pathName = "README.md";
var statusCode = Status.STATUS.WT_NEW;

before(function() {
this.status = new StatusFile({path: pathName, status: statusCode});
function testStatusFile(status) {
var statusFile = new StatusFile({
path: pathName,
status: Status.STATUS[status]
});
var specialFunction = status.replace(/^(WT|INDEX)_/, "");
specialFunction = "is" +
specialFunction[0] +
specialFunction.substring(1).toLowerCase();
if (/^WT_/.test(status)) {
assert.ok(statusFile.inWorkingTree());
assert.ok(!statusFile.inIndex());
}
if (/^INDEX_/.test(status)) {
assert.ok(!statusFile.inWorkingTree());
assert.ok(statusFile.inIndex());
}
assert.equal(statusFile.path(), pathName);
assert.equal(statusFile.statusBit(), Status.STATUS[status]);
assert.equal(statusFile.status(), status);
assert.ok(statusFile[specialFunction]());
}

it.skip("identifies the proper statuses for CURRENT", function() {
testStatusFile("CURRENT");
});

it.skip("identifies the proper statuses for WT_UNREADABLE", function() {
testStatusFile("WT_UNREADABLE");
});

it("identifies the proper statuses for WT_NEW", function() {
testStatusFile("WT_NEW");
});

it("identifies the proper statuses for WT_MODIFIED", function() {
testStatusFile("WT_MODIFIED");
});

it("identifies the proper statuses for WT_DELETED", function() {
testStatusFile("WT_DELETED");
});

it("identifies the proper statuses for WT_TYPECHANGE", function() {
testStatusFile("WT_TYPECHANGE");
});

it("identifies the proper statuses for WT_RENAMED", function() {
testStatusFile("WT_RENAMED");
});

it("identifies the proper statuses for IGNORED", function() {
testStatusFile("IGNORED");
});

it("passes the path to the working function", function() {
assert.equal(this.status.path(), pathName);
it("identifies the proper statuses for INDEX_NEW", function() {
testStatusFile("INDEX_NEW");
});

it("identifies the proper statuses", function() {
assert.ok(this.status.isNew());
assert.ok(!this.status.isModified());
it("identifies the proper statuses for INDEX_MODIFIED", function() {
testStatusFile("INDEX_MODIFIED");
});

it("detects working tree and index statuses", function() {
assert.ok(this.status.inWorkingTree());
assert.ok(!this.status.inIndex());
it("identifies the proper statuses for INDEX_DELETED", function() {
testStatusFile("INDEX_DELETED");
});

it("identifies the proper statuses for INDEX_TYPECHANGE", function() {
testStatusFile("INDEX_TYPECHANGE");
});

it("identifies the proper statuses for INDEX_RENAMED", function() {
testStatusFile("INDEX_RENAMED");
});

});

0 comments on commit ae74dfb

Please sign in to comment.