Skip to content

Commit cc2bad8

Browse files
committed
test(ng_mustache): added a test for filters
1 parent 1f3b858 commit cc2bad8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/core_dom/ng_mustache_spec.dart

+21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ main() {
77
TestBed _;
88
beforeEach(module((Module module) {
99
module.type(_ListenerDirective);
10+
module.type(_HelloFilter);
1011
}));
1112
beforeEach(inject((TestBed tb) => _ = tb));
1213

@@ -66,6 +67,18 @@ main() {
6667
$rootScope.$digest();
6768
expect(element.attr('multiline-attr')).toEqual('line1: L1\nline2: L2');
6869
}));
70+
71+
72+
it('should handle filters', inject((Compiler $compile, Scope $rootScope, Injector injector, DirectiveMap directives) {
73+
var element = $('<div>{{"World" | hello}}</div>');
74+
var template = $compile(element, directives);
75+
var block = template(injector);
76+
$rootScope.$digest();
77+
78+
element = $(block.elements);
79+
80+
expect(element.html()).toEqual('Hello, World!');
81+
}));
6982
});
7083

7184
describe('NgShow', () {
@@ -121,3 +134,11 @@ class _ListenerDirective implements TextChangeListener {
121134
_ListenerDirective(Logger this.logger);
122135
call(String text) => logger(text);
123136
}
137+
138+
@NgFilter(name:'hello')
139+
class _HelloFilter {
140+
call(String str) {
141+
return 'Hello, $str!';
142+
}
143+
}
144+

0 commit comments

Comments
 (0)