This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filter): allow map of filters to be registered
This feature adds similar functionality to what `$ControllerProvider.register` and `$CompileProvider.directive` currently provide by allowing a map of filter name/factories to be passed as the sole argument to `$FilterProvider.register` to register all of the specified filters. Closes #4036 Closes #4091
- Loading branch information
1 parent
587e8e2
commit 4033cf2
Showing
2 changed files
with
66 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
describe('$filter', function() { | ||
var $filterProvider, $filter; | ||
|
||
beforeEach(module(function(_$filterProvider_) { | ||
$filterProvider = _$filterProvider_; | ||
})); | ||
|
||
beforeEach(inject(function(_$filter_) { | ||
$filter = _$filter_; | ||
})); | ||
|
||
describe('provider', function() { | ||
it('should allow registration of filters', function() { | ||
var FooFilter = function() { | ||
return function() { return 'foo'; }; | ||
}; | ||
|
||
$filterProvider.register('foo', FooFilter); | ||
|
||
var fooFilter = $filter('foo'); | ||
expect(fooFilter()).toBe('foo'); | ||
}); | ||
|
||
it('should allow registration of a map of filters', function() { | ||
var FooFilter = function() { | ||
return function() { return 'foo'; }; | ||
}; | ||
|
||
var BarFilter = function() { | ||
return function() { return 'bar'; }; | ||
}; | ||
|
||
$filterProvider.register({ | ||
'foo': FooFilter, | ||
'bar': BarFilter | ||
}); | ||
|
||
var fooFilter = $filter('foo'); | ||
expect(fooFilter()).toBe('foo'); | ||
|
||
var barFilter = $filter('bar'); | ||
expect(barFilter()).toBe('bar'); | ||
}); | ||
}); | ||
}); |