From 1b16d71e6601ac10d329e6940e03ea72b2f13d63 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 5 May 2015 12:50:15 +0200 Subject: [PATCH] Added tests for Model.search(). --- public/assets/tests/model.js | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/public/assets/tests/model.js b/public/assets/tests/model.js index 0c30db2a1..4a892c707 100644 --- a/public/assets/tests/model.js +++ b/public/assets/tests/model.js @@ -201,6 +201,55 @@ test( "model basic tests", function() { }); +// search +test( "model search tests", function() { + + App.TicketPriority.refresh( [ + { + id: 1, + name: '1 low', + note: 'some note 1', + active: true, + created_at: '2014-06-10T11:17:34.000Z', + }, + { + id: 2, + name: '2 normal', + note: 'some note 2', + active: false, + created_at: '2014-06-10T10:17:33.000Z', + }, + { + id: 3, + name: '3 high', + note: 'some note 3', + active: true, + created_at: '2014-06-10T10:17:44.000Z', + }, + { + id: 4, + name: '4 very high', + note: 'some note 4', + active: true, + created_at: '2014-06-10T10:17:54.000Z', + }, + ] ) + priorities = App.TicketPriority.search({sortBy:'created_at', order: 'ASC'}) + equal( '2 normal', priorities[0].name, 'check 1 entry') + equal( '3 high', priorities[1].name, 'check 2 entry') + equal( '4 very high', priorities[2].name, 'check 3 entry') + equal( '1 low', priorities[3].name, 'check 4 entry') + equal( undefined, priorities[4], 'check 5 entry') + + priorities = App.TicketPriority.search({sortBy:'created_at', order: 'DESC'}) + equal( '1 low', priorities[0].name, 'check 4 entry') + equal( '4 very high', priorities[1].name, 'check 3 entry') + equal( '3 high', priorities[2].name, 'check 2 entry') + equal( '2 normal', priorities[3].name, 'check 1 entry') + equal( undefined, priorities[4], 'check 5 entry') + +}); + // model test( "model loadAssets tests - 1", function() { window.refreshCounter1 = 0