OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <title>iron-form-element-behavior</title> |
| 14 |
| 15 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 16 <script src="../../web-component-tester/browser.js"></script> |
| 17 |
| 18 <link rel="import" href="../../polymer/polymer.html"> |
| 19 <link rel="import" href="../iron-form-element-behavior.html"> |
| 20 <link rel="import" href="simple-element.html"> |
| 21 <link rel="import" href="simple-form.html"> |
| 22 </head> |
| 23 <body> |
| 24 |
| 25 <test-fixture id="basic"> |
| 26 <template> |
| 27 <form is="simple-form"></form> |
| 28 </template> |
| 29 </test-fixture> |
| 30 |
| 31 <script> |
| 32 suite('basic', function() { |
| 33 var form; |
| 34 |
| 35 setup(function() { |
| 36 form = fixture('basic'); |
| 37 }); |
| 38 |
| 39 test('elements fire an event when attached', function(done) { |
| 40 var element = document.createElement('input', 'simple-element'); |
| 41 |
| 42 var handler = sinon.spy(); |
| 43 form.addEventListener('iron-form-element-register', handler); |
| 44 |
| 45 form.appendChild(element); |
| 46 Polymer.Base.async(function() { |
| 47 expect(handler.callCount).to.be.equal(1); |
| 48 done(); |
| 49 }, 1); |
| 50 }); |
| 51 |
| 52 test('elements fire an event when detached', function(done) { |
| 53 var element = document.createElement('input', 'simple-element'); |
| 54 form.appendChild(element); |
| 55 element._parentForm = form; |
| 56 |
| 57 var handler = sinon.spy(); |
| 58 form.addEventListener('iron-form-element-unregister', handler); |
| 59 |
| 60 form.removeChild(element); |
| 61 Polymer.Base.async(function() { |
| 62 expect(handler.callCount).to.be.equal(1); |
| 63 done(); |
| 64 }, 1); |
| 65 }); |
| 66 }); |
| 67 |
| 68 </script> |
| 69 |
| 70 </body> |
| 71 </html> |
OLD | NEW |