| Index: third_party/pkg/angular/test/tools/html_extractor_spec.dart
|
| diff --git a/third_party/pkg/angular/test/tools/html_extractor_spec.dart b/third_party/pkg/angular/test/tools/html_extractor_spec.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..382059655abf363aedccfe72e62fc1c95a765563
|
| --- /dev/null
|
| +++ b/third_party/pkg/angular/test/tools/html_extractor_spec.dart
|
| @@ -0,0 +1,92 @@
|
| +library html_extractor_spec;
|
| +
|
| +import 'package:angular/tools/common.dart';
|
| +import 'package:angular/tools/html_extractor.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +import '../jasmine_syntax.dart';
|
| +import 'mock_io_service.dart';
|
| +
|
| +main() => describe('html_extractor', () {
|
| +
|
| + it('should extract text mustache expressions', () {
|
| + var ioService = new MockIoService({
|
| + 'foo.html': r'''
|
| + <div>foo {{ctrl.bar}} baz {{aux}}</div>
|
| + '''
|
| + });
|
| +
|
| + var extractor = new HtmlExpressionExtractor([], ioService);
|
| + extractor.crawl('/');
|
| + expect(extractor.expressions.toList()..sort(),
|
| + equals(['aux', 'ctrl.bar']));
|
| + });
|
| +
|
| + it('should extract attribute mustache expressions', () {
|
| + var ioService = new MockIoService({
|
| + 'foo.html': r'''
|
| + <div foo="foo-{{ctrl.bar}}" baz="{{aux}}-baz"></div>
|
| + '''
|
| + });
|
| +
|
| + var extractor = new HtmlExpressionExtractor([], ioService);
|
| + extractor.crawl('/');
|
| + expect(extractor.expressions.toList()..sort(),
|
| + equals(['aux', 'ctrl.bar']));
|
| + });
|
| +
|
| + it('should extract ng-repeat expressions', () {
|
| + var ioService = new MockIoService({
|
| + 'foo.html': r'''
|
| + <div ng-repeat="foo in ctrl.bar"></div>
|
| + '''
|
| + });
|
| +
|
| + var extractor = new HtmlExpressionExtractor([], ioService);
|
| + extractor.crawl('/');
|
| + expect(extractor.expressions.toList()..sort(),
|
| + equals(['ctrl.bar']));
|
| + });
|
| +
|
| + it('should extract expressions provided in the directive info', () {
|
| + var ioService = new MockIoService({});
|
| +
|
| + var extractor = new HtmlExpressionExtractor([
|
| + new DirectiveInfo('', [], ['foo', 'bar'])
|
| + ], ioService);
|
| + extractor.crawl('/');
|
| + expect(extractor.expressions.toList()..sort(),
|
| + equals(['bar', 'foo']));
|
| + });
|
| +
|
| + it('should extract expressions from expression attributes', () {
|
| + var ioService = new MockIoService({
|
| + 'foo.html': r'''
|
| + <foo bar="ctrl.baz"></foo>
|
| + '''
|
| + });
|
| +
|
| + var extractor = new HtmlExpressionExtractor([
|
| + new DirectiveInfo('foo', ['bar'])
|
| + ], ioService);
|
| + extractor.crawl('/');
|
| + expect(extractor.expressions.toList()..sort(),
|
| + equals(['ctrl.baz']));
|
| + });
|
| +
|
| + it('should ignore ng-repeat while extracting attribute expressions', () {
|
| + var ioService = new MockIoService({
|
| + 'foo.html': r'''
|
| + <div ng-repeat="foo in ctrl.bar"></div>
|
| + '''
|
| + });
|
| +
|
| + var extractor = new HtmlExpressionExtractor([
|
| + new DirectiveInfo('[ng-repeat]', ['ng-repeat'])
|
| + ], ioService);
|
| + extractor.crawl('/');
|
| + // Basically we don't want to extract "foo in ctrl.bar".
|
| + expect(extractor.expressions.toList()..sort(),
|
| + equals(['ctrl.bar']));
|
| + });
|
| +});
|
|
|