Fixes #61 - Order by timestamps with tests

This commit is contained in:
Arnaud Benard 2014-10-18 15:08:57 +01:00 committed by lilia
parent cc5327dbc9
commit e568e2c528
4 changed files with 31 additions and 3 deletions

View file

@ -149,7 +149,8 @@
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="views/message_view_test.js"></script>
<script type="text/javascript" src="views/list_view_test.js"></script>
<script type="text/javascript" src="views/list_view_test.js"></script>
<script type="text/javascript" src="views/threads_test.js"></script>
</body>

View file

@ -0,0 +1,22 @@
describe('Threads', function() {
it('should be ordered newest to oldest', function() {
// Timestamps
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate()+1);
// Add threads
Whisper.Threads.add({ timestamp: today });
Whisper.Threads.add({ timestamp: tomorrow });
var models = Whisper.Threads.models;
var firstTimestamp = models[0].get('timestamp').getTime();
var secondTimestamp = models[1].get('timestamp').getTime();
// Compare timestamps
assert(firstTimestamp > secondTimestamp);
});
});