Last active
August 29, 2015 14:05
-
-
Save henrik/06122aedab2f2eace527 to your computer and use it in GitHub Desktop.
Spec for an AngularJS filter that injects another filter.
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
# NOTE: We're overriding a built-in filter by the same name. | |
app.filter "currency", (numberFilter) -> | |
(text, currencyName) -> | |
numberFilter(text) + " " + currencyName |
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
#= require helpers/angular_helper | |
#= require filters/currency | |
describe "currency", -> | |
it "appends the provided currency to the formatted number", -> | |
module ($provide) -> | |
$provide.value "numberFilter", (number) -> "[formatted #{number}]" | |
null | |
inject (currencyFilter) -> | |
expect(currencyFilter(1234, "SEK")).toEqual("[formatted 1234] SEK") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment