From 8fa84c507406ac3186550aab285673eb65b75c4d Mon Sep 17 00:00:00 2001
From: Carlos Jimenez <=>
Date: Mon, 13 Aug 2018 09:32:33 +0200
Subject: [PATCH] #517 ticket index unit tests

---
 client/ticket/src/index/index.spec.js | 56 +++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/client/ticket/src/index/index.spec.js b/client/ticket/src/index/index.spec.js
index a6cd7d18cd..b27f4d224b 100644
--- a/client/ticket/src/index/index.spec.js
+++ b/client/ticket/src/index/index.spec.js
@@ -14,6 +14,56 @@ describe('ticket', () => {
             controller = $componentController('vnTicketIndex');
         }));
 
+        describe('exprBuilder()', () => {
+            it('should return a formated object with the id in case of search', () => {
+                let param = 'search';
+                let value = 1;
+                let result = controller.exprBuilder(param, value);
+
+                expect(result).toEqual({id: 1});
+            });
+
+            it('should return a formated object with the nickname in case of search', () => {
+                let param = 'search';
+                let value = 'Bruce';
+                let result = controller.exprBuilder(param, value);
+
+                expect(result).toEqual({nickname: {regexp: 'Bruce'}});
+            });
+
+            it('should return a formated object with the date in case of from', () => {
+                let param = 'from';
+                let value = 'Fri Aug 10 2018 11:39:21 GMT+0200';
+                let result = controller.exprBuilder(param, value);
+
+                expect(result).toEqual({shipped: {gte: 'Fri Aug 10 2018 11:39:21 GMT+0200'}});
+            });
+
+            it('should return a formated object with the date in case of to', () => {
+                let param = 'to';
+                let value = 'Fri Aug 10 2018 11:39:21 GMT+0200';
+                let result = controller.exprBuilder(param, value);
+
+                expect(result).toEqual({shipped: {lte: 'Fri Aug 10 2018 11:39:21 GMT+0200'}});
+            });
+
+            it('should return a formated object with the nickname in case of nickname', () => {
+                let param = 'nickname';
+                let value = 'Bruce';
+                let result = controller.exprBuilder(param, value);
+
+                expect(result).toEqual({nickname: {regexp: 'Bruce'}});
+            });
+
+            it('should return a formated object with the warehouseFk in case of warehouseFk', () => {
+                let param = 'warehouseFk';
+                let value = 'Silla';
+                let result = controller.exprBuilder(param, value);
+
+                expect(result).toEqual({warehouseFk: 'Silla'});
+            });
+        });
+
         describe('compareDate()', () => {
             it('should return warning when the date is the present', () => {
                 let date = new Date();
@@ -22,9 +72,9 @@ describe('ticket', () => {
                 expect(result).toEqual('warning');
             });
 
-            it('should return warning when the date is in the future', () => {
-                let date = '2518-05-19T00:00:00.000Z';
-                let result = controller.compareDate(date);
+            it('should return sucess when the date is in the future', () => {
+                let futureDate = '2518-05-19T00:00:00.000Z';
+                let result = controller.compareDate(futureDate);
 
                 expect(result).toEqual('success');
             });