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

Side by Side Diff: test/analyzer_test.dart

Issue 13592003: add support for template repeat (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer_test; 5 library analyzer_test;
6 6
7 import 'package:html5lib/dom.dart'; 7 import 'package:html5lib/dom.dart';
8 import 'package:html5lib/parser.dart'; 8 import 'package:html5lib/parser.dart';
9 import 'package:logging/logging.dart'; 9 import 'package:logging/logging.dart';
10 import 'package:unittest/compact_vm_config.dart'; 10 import 'package:unittest/compact_vm_config.dart';
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 var info = analyzeElement(elem); 425 var info = analyzeElement(elem);
426 426
427 expect(elem.attributes, equals({'instantiate': 'foo'})); 427 expect(elem.attributes, equals({'instantiate': 'foo'}));
428 expect(info, isNot(new isInstanceOf<TemplateInfo>('TemplateInfo')), 428 expect(info, isNot(new isInstanceOf<TemplateInfo>('TemplateInfo')),
429 reason: 'example is not a valid template'); 429 reason: 'example is not a valid template');
430 }); 430 });
431 431
432 test('template if (empty)', () { 432 test('template if (empty)', () {
433 var elem = parseSubtree('<template if="foo"></template>'); 433 var elem = parseSubtree('<template if="foo"></template>');
434 var info = analyzeElement(elem); 434 var info = analyzeElement(elem);
435 expect(info.hasIfCondition, false); 435 expect(info.hasCondition, false);
436 }); 436 });
437 437
438 test('template if', () { 438 test('template if', () {
439 var elem = parseSubtree('<template if="foo"><div>'); 439 var elem = parseSubtree('<template if="foo"><div>');
440 var div = elem.query('div'); 440 var div = elem.query('div');
441 TemplateInfo info = analyzeElement(elem); 441 TemplateInfo info = analyzeElement(elem);
442 expect(info.hasIfCondition, true); 442 expect(info.hasCondition, true);
443 expect(info.createdInCode, false); 443 expect(info.createdInCode, false);
444 expect(info.children[0].node, equals(div)); 444 expect(info.children[0].node, equals(div));
445 expect(info.children[0].createdInCode, true); 445 expect(info.children[0].createdInCode, true);
446 expect(div.id, ''); 446 expect(div.id, '');
447 expect(elem.attributes, equals({'if': 'foo'})); 447 expect(elem.attributes, equals({'if': 'foo'}));
448 expect(info.ifCondition, equals('foo')); 448 expect(info.ifCondition, equals('foo'));
449 expect(info.hasIterate, isFalse); 449 expect(info.hasLoop, isFalse);
450 expect(messages.length, 0); 450 expect(messages.length, 0);
451 }); 451 });
452 452
453 test('template instantiate if', () { 453 test('template instantiate if', () {
454 var elem = parseSubtree('<template instantiate="if foo"><div>'); 454 var elem = parseSubtree('<template instantiate="if foo"><div>');
455 var div = elem.query('div'); 455 var div = elem.query('div');
456 TemplateInfo info = analyzeElement(elem); 456 TemplateInfo info = analyzeElement(elem);
457 expect(info.hasIfCondition, true); 457 expect(info.hasCondition, true);
458 expect(info.createdInCode, false); 458 expect(info.createdInCode, false);
459 expect(info.children[0].node, equals(div)); 459 expect(info.children[0].node, equals(div));
460 expect(info.children[0].createdInCode, true); 460 expect(info.children[0].createdInCode, true);
461 expect(div.id, ''); 461 expect(div.id, '');
462 expect(elem.attributes, equals({'instantiate': 'if foo'})); 462 expect(elem.attributes, equals({'instantiate': 'if foo'}));
463 expect(info.ifCondition, equals('foo')); 463 expect(info.ifCondition, equals('foo'));
464 expect(info.hasIterate, isFalse); 464 expect(info.hasLoop, isFalse);
465 expect(messages.length, 0); 465 expect(messages.length, 0);
466 }); 466 });
467 467
468 test('if w/o template has warning', () { 468 test('if w/o template has warning', () {
469 var elem = parseSubtree('<div if="foo">'); 469 var elem = parseSubtree('<div if="foo">');
470 analyzeElement(elem); 470 analyzeElement(elem);
471 expect(messages.length, 1); 471 expect(messages.length, 1);
472 expect(messages[0].message, contains('template attribute is required')); 472 expect(messages[0].message, contains('template attribute is required'));
473 expect(messages[0].span, equals(elem.sourceSpan)); 473 expect(messages[0].span, equals(elem.sourceSpan));
474 }); 474 });
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 expect(other, isNull); 1033 expect(other, isNull);
1034 return; 1034 return;
1035 } 1035 }
1036 expect(summary.dartCodePath, equals(other.dartCodePath)); 1036 expect(summary.dartCodePath, equals(other.dartCodePath));
1037 expect(summary.outputFilename, equals(other.outputFilename)); 1037 expect(summary.outputFilename, equals(other.outputFilename));
1038 expect(summary.tagName, equals(other.tagName)); 1038 expect(summary.tagName, equals(other.tagName));
1039 expect(summary.extendsTag, equals(other.extendsTag)); 1039 expect(summary.extendsTag, equals(other.extendsTag));
1040 _compareSummary(summary.extendsComponent, other.extendsComponent); 1040 _compareSummary(summary.extendsComponent, other.extendsComponent);
1041 expect(summary.className, equals(other.className)); 1041 expect(summary.className, equals(other.className));
1042 } 1042 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698