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:
parent
d537d6a91f
commit
28290477f4
9 changed files with 5749 additions and 30 deletions
|
@ -56,6 +56,7 @@
|
|||
<ul class='volley'>
|
||||
<li class='message'>
|
||||
{{ message }}
|
||||
<span class='timestamp'>{{ timestamp }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
{{#attachments}}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue