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

Side by Side Diff: test/analyzer_test.dart

Issue 11416259: fix #136, support watch exprs and two way bindings for component fields (Closed) Base URL: https://github.com/dart-lang/dart-web-components.git@master
Patch Set: Created 8 years 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
« no previous file with comments | « lib/web_components.dart ('k') | test/data/expected/component_field_2way_test.html.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:unittest/vm_config.dart'; 10 import 'package:unittest/vm_config.dart';
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 expect(info.children[0].node, equals(div)); 456 expect(info.children[0].node, equals(div));
457 expect(info.children[0].createdInCode, true); 457 expect(info.children[0].createdInCode, true);
458 expect(div.id, ''); 458 expect(div.id, '');
459 expect(elem.attributes, equals({ 459 expect(elem.attributes, equals({
460 'iterate': 'foo in bar', 'is': 'x-list', 'id': '__e-0'})); 460 'iterate': 'foo in bar', 'is': 'x-list', 'id': '__e-0'}));
461 expect(info.ifCondition, isNull); 461 expect(info.ifCondition, isNull);
462 expect(info.loopVariable, equals('foo')); 462 expect(info.loopVariable, equals('foo'));
463 expect(info.loopItems, equals('bar')); 463 expect(info.loopItems, equals('bar'));
464 }); 464 });
465 465
466 test('data-value', () { 466 test('data-value - deprecated', () {
467 messages.clear();
467 var elem = parseSubtree('<li is="x-todo-row" data-value="todo:x"></li>'); 468 var elem = parseSubtree('<li is="x-todo-row" data-value="todo:x"></li>');
468 var info = analyzeElement(elem); 469 var info = analyzeElement(elem);
469 elem = elem.query('li');
470 expect(info.attributes, isEmpty); 470 expect(info.attributes, isEmpty);
471 expect(info.events, isEmpty); 471 expect(info.events, isEmpty);
472 expect(info.values, equals({'todo': 'x'})); 472 expect(info.values, equals({'todo': 'x'}));
473 expect(messages.length, 2);
474 expect(messages[0].message, contains('x-todo-row not found'));
475 expect(messages[0].span, equals(elem.sourceSpan));
476 expect(messages[1].message, contains('data-value is deprecated'));
477 expect(messages[1].span, equals(elem.sourceSpan));
478 });
479
480 test('component properties 1-way binding', () {
481 var files = parseFiles({
482 'index.html': '<head><link rel="components" href="foo.html">'
483 '<body><element name="x-bar" extends="x-foo" '
484 'constructor="Bar"></element>'
485 '<x-bar quux="{{123}}">',
486 'foo.html': '<body><element name="x-foo" constructor="Foo">'
487 });
488
489 var fileInfo = analyzeFiles(files);
490 var bar = fileInfo['index.html'].query('x-bar');
491 expect(bar.hasDataBinding, true);
492 expect(bar.attributes.keys, ['quux']);
493 expect(bar.attributes['quux'].customTwoWayBinding, false);
494 expect(bar.attributes['quux'].boundValue, '123');
495 });
496
497 test('component properties 2-way binding', () {
498 var files = parseFiles({
499 'index.html': '<head><link rel="components" href="foo.html">'
500 '<body><element name="x-bar" extends="x-foo" '
501 'constructor="Bar"></element>'
502 '<x-bar bind-quux="assignable">',
503 'foo.html': '<body><element name="x-foo" constructor="Foo">'
504 });
505
506 var fileInfo = analyzeFiles(files)['index.html'];
507 var bar = fileInfo.query('x-bar');
508 expect(bar.component, same(fileInfo.declaredComponents[0]));
509 expect(bar.hasDataBinding, true);
510 expect(bar.attributes.keys, ['quux']);
511 expect(bar.attributes['quux'].customTwoWayBinding, true);
512 expect(bar.attributes['quux'].boundValue, 'assignable');
473 }); 513 });
474 514
475 group('analyzeDefinitions', () { 515 group('analyzeDefinitions', () {
476 test('links', () { 516 test('links', () {
477 var info = analyzeDefinitionsInTree(parse( 517 var info = analyzeDefinitionsInTree(parse(
478 '<head>' 518 '<head>'
479 '<link rel="components" href="foo.html">' 519 '<link rel="components" href="foo.html">'
480 '<link rel="something" href="bar.html">' 520 '<link rel="something" href="bar.html">'
481 '<link rel="components" hrefzzz="baz.html">' 521 '<link rel="components" hrefzzz="baz.html">'
482 '<link rel="components" href="quux.html">' 522 '<link rel="components" href="quux.html">'
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 var info = fileInfo['index.html']; 761 var info = fileInfo['index.html'];
722 expect(info.components.keys, equals(['x-bar', 'x-foo'])); 762 expect(info.components.keys, equals(['x-bar', 'x-foo']));
723 763
724 var compInfo = fileInfo['foo.html'].declaredComponents[0]; 764 var compInfo = fileInfo['foo.html'].declaredComponents[0];
725 expect(info.query('x-foo').component, equals(compInfo)); 765 expect(info.query('x-foo').component, equals(compInfo));
726 compInfo = fileInfo['bar.html'].declaredComponents[0]; 766 compInfo = fileInfo['bar.html'].declaredComponents[0];
727 expect(info.query('x-bar').component, equals(compInfo)); 767 expect(info.query('x-bar').component, equals(compInfo));
728 }); 768 });
729 }); 769 });
730 } 770 }
OLDNEW
« no previous file with comments | « lib/web_components.dart ('k') | test/data/expected/component_field_2way_test.html.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698