Skip to content

Commit

Permalink
Merge pull request hubotio#191 from ejfinneran/xmpp-username-fix
Browse files Browse the repository at this point in the history
If no name is given for the user, default to ID
  • Loading branch information
atmos committed Nov 24, 2011
2 parents 6745673 + dd49b49 commit 8f8165c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/user.coffee
Expand Up @@ -8,6 +8,7 @@ class User
constructor: (@id, options = { }) ->
for k of (options or { })
@[k] = options[k]
@['name'] ||= @id

module.exports = User

14 changes: 14 additions & 0 deletions test/user_test.coffee
@@ -0,0 +1,14 @@
User = require '../src/user'
assert = require 'assert'


user = new User "Fake User", {name: 'fake', type: "groupchat"}
assert.equal "Fake User", user.id
assert.equal "groupchat", user.type
assert.equal "fake", user.name

user = new User "Fake User", {room: "chat@room.jabber", type: "groupchat"}
assert.equal "Fake User", user.id
assert.equal "chat@room.jabber", user.room
assert.equal "groupchat", user.type
assert.equal "Fake User", user.name # Make sure that if no name is given, we fallback to the ID

0 comments on commit 8f8165c

Please sign in to comment.