This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Humanified filter wasn't flexible enough for our facets. It assumed it was getting in strings that the desired value was after a '.' (I.E. a nested value). With facet terms we were passing that value directly causing part of terms not to be displayed. Closes #374
- Loading branch information
Matthew Schranz
committed
Feb 25, 2015
1 parent
643ddc1
commit b2ab4d5
Showing
3 changed files
with
58 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 37 additions & 31 deletions
68
app/scripts/components/ui/string/tests/humanifyfilter.tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
describe("Humanify Filter:", function() { | ||
// Initialization of the AngularJS application before each test case | ||
beforeEach(module("ngApp.components")); | ||
|
||
var sampleString = "file.archive.archive_uuid"; | ||
var startsWith_ = "_missing"; | ||
|
||
it("should have a humanify filter", inject(function ($filter) { | ||
expect($filter("humanify")).not.to.be.null; | ||
})); | ||
|
||
it("should split on . ", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString); | ||
expect(humanified).to.not.contain("."); | ||
})); | ||
|
||
it("should replace _ with spaces", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString); | ||
expect(humanified).to.not.contain("_"); | ||
})); | ||
|
||
it("should remove _ if it is the first character", inject(function($filter) { | ||
var humanified2 = $filter("humanify")(startsWith_); | ||
expect(humanified2).to.not.contain("_"); | ||
expect(humanified2[0]).to.not.equal(" "); | ||
})); | ||
|
||
it("capitalize the first letter", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString); | ||
var split = sampleString.split("."); | ||
expect(humanified[0]).to.equal(split[split.length-1].charAt(0).toUpperCase()); | ||
})); | ||
// Initialization of the AngularJS application before each test case | ||
beforeEach(module("ngApp.components")); | ||
|
||
var sampleString = "file.archive.archive_uuid"; | ||
var startsWith_ = "_missing"; | ||
|
||
it("should have a humanify filter", inject(function ($filter) { | ||
expect($filter("humanify")).not.to.be.null; | ||
})); | ||
|
||
it("should split on . ", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString); | ||
expect(humanified).to.not.contain("."); | ||
})); | ||
|
||
it("should replace _ with spaces", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString); | ||
expect(humanified).to.not.contain("_"); | ||
})); | ||
|
||
it("should remove _ if it is the first character", inject(function($filter) { | ||
var humanified2 = $filter("humanify")(startsWith_); | ||
expect(humanified2).to.not.contain("_"); | ||
expect(humanified2[0]).to.not.equal(" "); | ||
})); | ||
|
||
it("capitalize the first letter", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString); | ||
var split = sampleString.split("."); | ||
expect(humanified[0]).to.equal(split[split.length-1].charAt(0).toUpperCase()); | ||
})); | ||
|
||
it("should not split when dealing with facets", inject(function ($filter) { | ||
var humanified = $filter("humanify")(sampleString, true, true); | ||
var split = sampleString.replace(/\./, " ").trim(); | ||
expect(humanified).to.equal("File Archive Archive_uuid"); | ||
})); | ||
|
||
}); |