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

Commit

Permalink
fix(files): Size filter handles undefined val.
Browse files Browse the repository at this point in the history
Closes #835
  • Loading branch information
mjschranz committed May 27, 2015
1 parent 4777af5 commit 0509a52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/scripts/components/ui/file/file.filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module ngApp.components.ui.file {

constructor() {
return function (val: number) {
var formattedVal: string;
var formattedVal: string = "0 B";

if (val >= FileSize.BYTES_TB_LIMIT) {
formattedVal = (val / FileSize.BYTES_PB).toFixed(2) + " PB";
Expand All @@ -25,7 +25,7 @@ module ngApp.components.ui.file {
formattedVal = (val / FileSize.BYTES_MB).toFixed(0) + " MB";
} else if (val >= FileSize.BYTES_KB) {
formattedVal = (val / FileSize.BYTES_KB).toFixed(0) + " KB";
} else {
} else if (val) {
formattedVal = val + " B";
}

Expand Down
6 changes: 6 additions & 0 deletions app/scripts/components/ui/file/tests/sizefilter.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ describe("File Size Filter:", function () {
expect(formattedSize).to.equal("999 B");
}));

it("should filter 0 B when no value given", inject(function ($filter) {
var formattedSize = "0 B";
formattedSize = $filter("size")();
expect(formattedSize).to.equal("0 B");
}));

});

0 comments on commit 0509a52

Please sign in to comment.