Skip to content

Commit

Permalink
Merge 7ea085c into f523b6b
Browse files Browse the repository at this point in the history
  • Loading branch information
vanadium23 committed May 28, 2015
2 parents f523b6b + 7ea085c commit 470496c
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions test/tests/status_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,38 @@ 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});
});
var checkStatusFile = function(status) {
it("identifies the proper statuses for " + status, function() {
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("passes the path to the working function", function() {
assert.equal(this.status.path(), pathName);
});
for (var status in Status.STATUS) {
if (status === "CURRENT" || status === "WT_UNREADABLE") {
continue;
}
checkStatusFile(status);
}

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

it("detects working tree and index statuses", function() {
assert.ok(this.status.inWorkingTree());
assert.ok(!this.status.inIndex());
});
});

0 comments on commit 470496c

Please sign in to comment.