mirror of
https://github.com/danog/gift.git
synced 2025-01-21 21:41:13 +01:00
add Actor#hash
This commit is contained in:
parent
5486623300
commit
ce62b82899
@ -1,5 +1,9 @@
|
||||
crypto = require 'crypto'
|
||||
|
||||
module.exports = class Actor
|
||||
constructor: (@name, @email) ->
|
||||
if email
|
||||
@hash = crypto.createHash("md5").update(@email, "ascii").digest("hex")
|
||||
|
||||
# Public: Get a string representation of the Actor.
|
||||
toString: ->
|
||||
|
@ -18,6 +18,13 @@ describe "Actor", ->
|
||||
actor.toString().should.eql "bob <bob@example.com>"
|
||||
|
||||
|
||||
describe "#hash", ->
|
||||
actor = new Actor "bob", "bob@example.com"
|
||||
|
||||
it "is the md5 hash of the email", ->
|
||||
actor.hash.should.eql "4b9bb80620f03eb3719e0a061c14283d"
|
||||
|
||||
|
||||
describe ".from_string", ->
|
||||
describe "with a name and email", ->
|
||||
actor = Actor.from_string "bob <bob@example.com>"
|
||||
|
Loading…
x
Reference in New Issue
Block a user