aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorColin Casey2013-09-21 01:24:39 -0300
committerPete Bacon Darwin2013-10-01 10:26:36 +0100
commit4033cf28142664c52aa7b4bc95340ac913397ac8 (patch)
tree923a8e8d555feb24d4241617ff5aea4c4df5fe19 /test
parent587e8e2ba5feb275f14d259afb72ae6b77dfef18 (diff)
downloadangular.js-4033cf28142664c52aa7b4bc95340ac913397ac8.tar.bz2
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
Diffstat (limited to 'test')
-rw-r--r--test/ng/filterSpec.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/ng/filterSpec.js b/test/ng/filterSpec.js
new file mode 100644
index 00000000..fc0571cb
--- /dev/null
+++ b/test/ng/filterSpec.js
@@ -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');
+ });
+ });
+}); \ No newline at end of file