Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/pkg/angular/test/directive/ng_template_spec.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/directive/ng_template_spec.dart
diff --git a/third_party/pkg/angular/test/directive/ng_template_spec.dart b/third_party/pkg/angular/test/directive/ng_template_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0dccfd3a954efc54c38ed15ad67e5855417c5d5c
--- /dev/null
+++ b/third_party/pkg/angular/test/directive/ng_template_spec.dart
@@ -0,0 +1,62 @@
+library ng_template_spec;
+
+import '../_specs.dart';
+
+main() {
+ describe('NgTemplateDirective', () {
+ TestBed _;
+ var element;
+
+ they(should, htmlForElements, callback) {
+ htmlForElements.forEach((html) {
+ var tagName = html.contains('<template') ? 'template' : 'script';
+ describe('$tagName[type="text/ng-template"]', () {
+ beforeEach(inject((TestBed tb) => _ = tb));
+ it(should, () {
+ element = $(html);
+ inject(callback);
+ });
+ });
+ });
+ }
+
+ they('should populate TemplateCache with contents of a ng-template template element',
+ [ // <template>
+ '<div>foo' +
+ '<template id="/ignore">ignore me</template>' +
+ '<template type="text/ng-template" id="/myTemplate.html"><x>{{y}}</x></template>' +
+ '</div>',
+ // <script>
+ '<div>foo' +
+ '<script id="/ignore">ignore me</script>' +
+ '<script type="text/ng-template" id="/myTemplate.html"><x>{{y}}</x></script>' +
+ '</div>'],
+ (Injector injector, Compiler compiler, TemplateCache templateCache) {
+ compiler(element)(injector, element);
+ expect(templateCache.get('/ignore')).toBeNull();
+ expect(templateCache.get('/myTemplate.html').responseText).toEqual('<x>{{y}}</x>');
+ }
+ );
+
+ they('should not compile template elements',
+ [ // <template>
+ '<div>foo' +
+ '<template type="text/javascript">some {{binding}} <div></div></template>' +
+ '<template type="text/ng-template" id="/some">other {{binding}} <div></div></template>' +
+ '</div>',
+ // <script>
+ '<div>foo' +
+ '<script type="text/javascript">some {{binding}} <div></div></script>' +
+ '<script type="text/ng-template" id="/some">other {{binding}} <div></div></script>' +
+ '</div>'],
+ (Injector injector, Compiler compiler, TemplateCache templateCache, Scope scope) {
+ var templates = element.contents();
+ compiler(element)(injector, element);
+
+ microLeap();
+ // This binding should have been left alone (i.e. not interpolated).
+ expect(templates[2].innerHtml).toEqual('other {{binding}} <div></div>');
+ }
+ );
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698