Skip to content

Instantly share code, notes, and snippets.

@henrik
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik/06122aedab2f2eace527 to your computer and use it in GitHub Desktop.
Save henrik/06122aedab2f2eace527 to your computer and use it in GitHub Desktop.
Spec for an AngularJS filter that injects another filter.
# NOTE: We're overriding a built-in filter by the same name.
app.filter "currency", (numberFilter) ->
(text, currencyName) ->
numberFilter(text) + " " + currencyName
#= 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