Nicer timestamps with momentjs

This dependency may be a little heavy for our current use case, but we can
roll with it for now and find something slimmer if it turns out yagni.

Closes #77
Closes #40
This commit is contained in:
lilia 2014-11-11 00:35:18 -08:00
parent d537d6a91f
commit 28290477f4
9 changed files with 5749 additions and 30 deletions

View file

@ -56,6 +56,7 @@
<ul class='volley'>
<li class='message'>
{{ message }}
<span class='timestamp'>{{ timestamp }}</span>
</li>
</ul>
{{#attachments}}

View file

@ -18,6 +18,18 @@ describe('MessageView', function() {
assert.match(view.$el.html(), /goodbye world/);
});
it('should have a nice timestamp', function() {
var view = new Whisper.MessageView({model: message});
message.set({'timestamp': new Date().getTime() - 5000});
assert.match(view.$el.html(), /seconds ago/);
message.set({'timestamp': new Date().getTime() - 60000});
assert.match(view.$el.html(), /minute ago/);
message.set({'timestamp': new Date().getTime() - 3600000});
assert.match(view.$el.html(), /hour ago/);
});
it('should go away when the model is destroyed', function() {
var view = new Whisper.MessageView({model: message});
var div = $('<div>').append(view.$el);