commit 3a94391142c7374836f5b77e9307bd4f5e98d818 Author: Tatiana Ovchinnikova Date: Tue Sep 1 13:16:12 2020 -0500 Make timezone tests work Timezone JS tests have no output expectations but Jasmine Spec Runner marks them 'passed' only adding "SPEC HAS NO EXPECTATIONS" into the tests names. This patch fixes it and adds one more test. Partial-Bug: #1894127 Change-Id: I0d760f26d064cbc4fd019f1b51c97b88fa6c7917 diff --git a/horizon/static/framework/util/timezones/timezone.service.spec.js b/horizon/static/framework/util/timezones/timezone.service.spec.js index 51c4f21..a719e92 100644 --- a/horizon/static/framework/util/timezones/timezone.service.spec.js +++ b/horizon/static/framework/util/timezones/timezone.service.spec.js @@ -17,34 +17,43 @@ 'use strict'; describe('horizon.framework.util.timezones.service', function () { - var service; + var service, $httpBackend; + var testData = {timezone_dict: { + "Asia/Shanghai": "+0800", + UTC: "+0000" + }}; + beforeEach(module('horizon.framework')); - beforeEach(inject(function($injector) { + beforeEach(inject(function ($injector, _$httpBackend_) { service = $injector.get('horizon.framework.util.timezones.service'); + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('/api/timezones/').respond(testData); })); - it('defines the service', function() { + it('defines the service', function () { expect(service).toBeDefined(); }); + it('defines getTimeZones', function () { + expect(service.getTimeZones()).toBeDefined(); + }); + describe('get timezone offset', function () { it('returns +0000(UTC offset) if nothing', function () { + service.getTimeZoneOffset().then(getResult); function getResult(result) { expect(result).toBe('+0000'); } - - service.getTimeZoneOffset().then(getResult); + $httpBackend.flush(); }); - it('returns the timezone offset', function() { - + it('returns the timezone offset', function () { + service.getTimeZoneOffset('Asia/Shanghai').then(getResult); function getResult(result) { expect(result).toBe('+0800'); } - - service.getTimeZoneOffset('Asia/Shanghai').then(getResult); - + $httpBackend.flush(); }); }); }); // end of horizon.framework.util.timezones