From b250d10320763c62c4e762e7c56658a7e214c84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 30 Sep 2014 17:55:07 +0200 Subject: [PATCH] Trying to fox unit tests for sharePanelCtrl --- src/test/specs/sharePanelCtrl-specs.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/specs/sharePanelCtrl-specs.js b/src/test/specs/sharePanelCtrl-specs.js index 4c36e8fe156..5b712bbba7a 100644 --- a/src/test/specs/sharePanelCtrl-specs.js +++ b/src/test/specs/sharePanelCtrl-specs.js @@ -1,7 +1,8 @@ define([ './helpers', + 'moment', 'controllers/sharePanelCtrl' -], function(helpers) { +], function(helpers, moment) { 'use strict'; describe('SharePanelCtrl', function() { @@ -12,6 +13,10 @@ define([ beforeEach(ctx.providePhase()); beforeEach(ctx.createControllerPhase('SharePanelCtrl')); + function getDate(year, month, day) { + return moment.utc(new Date(year, month, day)).toDate(); + } + describe('shareUrl with current time range and panel', function() { it('should generate share url relative time', function() { @@ -26,7 +31,7 @@ define([ it('should generate share url absolute time', function() { ctx.$location.path('/test'); ctx.scope.panel = { id: 22 }; - ctx.timeSrv.time = { from: new Date(2012,1,1), to: new Date(2014,3,5) }; + ctx.timeSrv.time = { from: getDate(2012,1,1), to: new Date(2014,3,5) }; ctx.scope.buildUrl(); expect(ctx.scope.shareUrl).to.be('http://server/#/test?from=1328050800000&to=1396648800000&panelId=22&fullscreen');