Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(tables): Fix failing sort tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Schranz committed Apr 27, 2015
1 parent 5ad0df5 commit 63b9343
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/scripts/components/tables/tables.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/components/tables/tests/table.sort.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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'; });
Expand Down

0 comments on commit 63b9343

Please sign in to comment.