diff --git a/platform/features/listview/bundle.js b/platform/features/listview/bundle.js index f1082fb35b..723a673506 100644 --- a/platform/features/listview/bundle.js +++ b/platform/features/listview/bundle.js @@ -49,7 +49,7 @@ { "key": "ListViewController", "implementation": ListViewController, - "depends": ["$scope"] + "depends": ["$scope", "formatService"] } ], "directives": [ diff --git a/platform/features/listview/src/controllers/ListViewController.js b/platform/features/listview/src/controllers/ListViewController.js index 3dd99bb02f..d5eb58085a 100644 --- a/platform/features/listview/src/controllers/ListViewController.js +++ b/platform/features/listview/src/controllers/ListViewController.js @@ -21,7 +21,7 @@ *****************************************************************************/ define(function () { - function ListViewController($scope) { + function ListViewController($scope, formatService) { this.$scope = $scope; $scope.orderByField = 'title'; $scope.reverseSort = false; @@ -30,6 +30,8 @@ define(function () { var unlisten = $scope.domainObject.getCapability('mutation') .listen(this.updateView.bind(this)); + this.utc = formatService.getFormat('utc'); + $scope.$on('$destroy', function () { unlisten(); }); @@ -50,17 +52,13 @@ define(function () { icon: child.getCapability('type').getCssClass(), title: child.getModel().name, type: child.getCapability('type').getName(), - persisted: new Date( - child.getModel().persisted - ).toUTCString(), - modified: new Date( - child.getModel().modified - ).toUTCString(), + persisted: this.utc.format(child.getModel().persisted), + modified: this.utc.format(child.getModel().modified), asDomainObject: child, location: child.getCapability('location'), action: child.getCapability('action') }; - }); + }, this); }; return ListViewController; diff --git a/platform/features/listview/test/controllers/ListViewControllerSpec.js b/platform/features/listview/test/controllers/ListViewControllerSpec.js index a5d6e06a20..f18d77a9ae 100644 --- a/platform/features/listview/test/controllers/ListViewControllerSpec.js +++ b/platform/features/listview/test/controllers/ListViewControllerSpec.js @@ -31,7 +31,9 @@ define( controller, childModel, typeCapability, - mutationCapability; + mutationCapability, + formatService; + beforeEach(function () { unlistenFunc = jasmine.createSpy("unlisten"); @@ -41,6 +43,18 @@ define( ); mutationCapability.listen.andReturn(unlistenFunc); + formatService = jasmine.createSpyObj( + "formatService", + ["getFormat"] + ); + formatService.getFormat.andReturn(jasmine.createSpyObj( + 'utc', + ["format"] + )); + formatService.getFormat().format.andCallFake(function (v) { + return "formatted " + v; + }); + typeCapability = jasmine.createSpyObj( "typeCapability", ["getCssClass", "getName"] @@ -94,20 +108,27 @@ define( ); scope.domainObject = domainObject; - controller = new ListViewController(scope); + controller = new ListViewController(scope, formatService); waitsFor(function () { return scope.children; }); }); + + it("uses the UTC time format", function () { + expect(formatService.getFormat).toHaveBeenCalledWith('utc'); + }); + it("updates the view", function () { expect(scope.children[0]).toEqual( { icon: "icon-folder", title: "Battery Charge Status", type: "Folder", - persisted: "Wed, 07 Jun 2017 20:34:57 GMT", - modified: "Wed, 07 Jun 2017 20:34:57 GMT", + persisted: formatService.getFormat('utc') + .format(childModel.persisted), + modified: formatService.getFormat('utc') + .format(childModel.modified), asDomainObject: childObject, location: '' }