From e568e2c52862de7da22b83054298b7f2af344abb Mon Sep 17 00:00:00 2001 From: Arnaud Benard Date: Sat, 18 Oct 2014 15:08:57 +0100 Subject: [PATCH] Fixes #61 - Order by timestamps with tests --- index.html | 2 +- js/models/threads.js | 7 ++++++- test/test_views.html | 3 ++- test/views/threads_test.js | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 test/views/threads_test.js diff --git a/index.html b/index.html index ae9b2b7da2..da54265b3d 100644 --- a/index.html +++ b/index.html @@ -33,7 +33,7 @@
- + + diff --git a/test/views/threads_test.js b/test/views/threads_test.js new file mode 100644 index 0000000000..c68b738765 --- /dev/null +++ b/test/views/threads_test.js @@ -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); + }); + + +});