From 63b93431df510b01e841790a8e1d2275bb6de020 Mon Sep 17 00:00:00 2001 From: Matthew Schranz <mschranz@oicr.on.ca> Date: Mon, 27 Apr 2015 11:06:08 -0400 Subject: [PATCH] fix(tables): Fix failing sort tests --- app/scripts/components/tables/tables.controllers.ts | 2 +- app/scripts/components/tables/tests/table.sort.tests.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/scripts/components/tables/tables.controllers.ts b/app/scripts/components/tables/tables.controllers.ts index 41e627e3d..5f8e7c5b0 100644 --- a/app/scripts/components/tables/tables.controllers.ts +++ b/app/scripts/components/tables/tables.controllers.ts @@ -70,7 +70,7 @@ module ngApp.components.tables.controllers { // check localStorage for saved sorting var sortColumnsSaved = JSON.parse(this.$window.localStorage.getItem(this.$scope.config.title + '-sort')); _.each(sortColumnsSaved, (savedCol: Object) => { - if(savedCol) { + if (savedCol) { var sortObj = _.find($scope.sortColumns, (col: Object) => { return col.key === savedCol.key; }); sortObj.sort = savedCol.sort || sortObj.sort; sortObj.order = savedCol.order || sortObj.order; diff --git a/app/scripts/components/tables/tests/table.sort.tests.js b/app/scripts/components/tables/tests/table.sort.tests.js index ce7ad670b..687a345dd 100644 --- a/app/scripts/components/tables/tests/table.sort.tests.js +++ b/app/scripts/components/tables/tests/table.sort.tests.js @@ -5,6 +5,11 @@ describe('Tables:', function () { describe('TableSortController:', function () { + beforeEach(inject(function ($window) { + // Clear localStorage system to prevent oddities from tests. + $window.localStorage.setItem("test-sort", "[]"); + })); + it('should process sorting from url on load', inject(function ($rootScope, $controller, LocationService) { var scope = $rootScope.$new(); scope.paging = { @@ -23,7 +28,6 @@ describe('Tables:', function () { sortable: true }] }; - var wc = $controller('TableSortController', { $scope: scope, LocationService: LocationService }); var fileSizeSort = _.find(wc.$scope.sortColumns, function(col) { return col.key === 'file_size'; }); var fileNameSort = _.find(wc.$scope.sortColumns, function(col) { return col.key === 'file_name'; });