FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix signature.now and add signature tests by maxkorp · Pull Request #308 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) .json  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion generate/input/descriptor.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,10 @@
"functions": {
"git_signature_new": {
"isAsync": false
}
},
"git_signature_now": {
"isAsync": false
}
}
},
"smart": {
Expand Down
35 changes: 35 additions & 0 deletions test/tests/signature.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var assert = require("assert");

describe("Signature", function() {

var Signature = require("../../lib/signature");
var name = "Bob Gnarley";
var email = "gnarlee@bob.net";
var arbitraryDate = 123456789;
var timezoneOffset = 60;

it("can be created at an arbitrary time", function() {
var create = Signature.create;
var signature = create(name, email, arbitraryDate, timezoneOffset);

assert.equal(signature.name(), name);
assert.equal(signature.email(), email);
assert.equal(signature.when().time(), arbitraryDate);
assert.equal(signature.when().offset(), 60);

});

it("can be created now", function() {

var signature = Signature.now(name, email);
var now = new Date();
var when = signature.when();
var diff = Math.abs(when.time() - now/1000);
assert.equal(signature.name(), name);
assert.equal(signature.email(), email);
assert(diff <= 1);

// libgit2 does its timezone offsets backwards from javascript
assert.equal(when.offset(), -now.getTimezoneOffset());
});
});

Back | FazBrowse Home | New Git URL