github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/public/static/js/tests/services.mci_time.test.js (about) 1 /** 2 * services.mci_time.test.js 3 * 4 * Created on: September 26, 2013 5 * Author: Valeri Karpov 6 * 7 * Karma-based unit tests for mciTime service (see public/static/js/tests/conf/karma.conf.js) 8 * 9 */ 10 11 describe('mciTime', function() { 12 beforeEach(module('MCI')); 13 14 var dateFromMillis = function(ms) { 15 return new Date(ms); 16 } 17 18 it("should return 0 for undefined parameters", inject(function(mciTime) { 19 expect(mciTime.finishConditional()).toBe(0); 20 })); 21 22 it("should return 0 for invalid start", inject(function(mciTime) { 23 expect(mciTime.finishConditional("")).toBe(0); 24 })); 25 26 it("should return difference between start and now if finish is undefined", inject(function(mciTime) { 27 mciTime.now = function() { 28 return new Date(26); 29 }; 30 31 expect(mciTime.finishConditional(dateFromMillis(1))).toBe(25); 32 })); 33 34 it("should return difference between start and finish when both are defined", inject(function(mciTime) { 35 mciTime.now = function() { 36 return null; 37 }; 38 39 expect(mciTime.finishConditional(dateFromMillis(1), dateFromMillis(51))).toBe(50); 40 })); 41 });