OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- Copyright (c) 2014 Google Inc. All rights reserved. --> |
| 3 <html> |
| 4 <head> |
| 5 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1.0, user-scalable=yes"> |
| 6 <title>google-plusone Basic Tests</title> |
| 7 <script src="../../webcomponentsjs/webcomponents.min.js"></script> |
| 8 <link rel="import" href="../../polymer-test-tools/tools.html"> |
| 9 <script src="../../polymer-test-tools/htmltest.js"></script> |
| 10 <script src="../../sinon-browser-only/sinon.js"></script> |
| 11 <link rel="import" href="../google-hangout-button.html"> |
| 12 </head> |
| 13 <body> |
| 14 <google-hangout-button |
| 15 type="party" |
| 16 apps="[{'app_id': '184219133185', 'start_data': 'dQw4w9WgXcQ', 'app_type
': 'ROOM_APP' }]" |
| 17 topic="test topic" |
| 18 invites="[{ id: 'foo@example.com', invite_type: 'EMAIL' }]" |
| 19 width="72"> |
| 20 </google-hangout-button> |
| 21 <script> |
| 22 function testIframeCreated(hangoutButton) { |
| 23 chai.assert.ok(hangoutButton.shadowRoot.querySelector('iframe')); |
| 24 } |
| 25 |
| 26 function testHangoutArgumentsAreApplied(hangoutButton, apiSpy) { |
| 27 chai.assert.ok(apiSpy.calledOnce); |
| 28 chai.assert.ok(apiSpy.calledWith(sinon.match.any, sinon.match({ |
| 29 'hangout_type': 'party' |
| 30 })), 'Loaded hangout type different than requested type'); |
| 31 |
| 32 chai.assert.ok(apiSpy.calledWith(sinon.match.any, sinon.match({ |
| 33 'initial_apps': "[{'app_id': '184219133185', 'start_data': " + |
| 34 "'dQw4w9WgXcQ', 'app_type': 'ROOM_APP' }]" |
| 35 })), 'Loaded apps different than requested apps'); |
| 36 |
| 37 chai.assert.ok(apiSpy.calledWith(sinon.match.any, sinon.match({ |
| 38 'topic': "test topic" |
| 39 })), 'Loaded topic different than requested topic'); |
| 40 |
| 41 chai.assert.ok(apiSpy.calledWith(sinon.match.any, sinon.match({ |
| 42 'invites': "[{ id: 'foo@example.com', invite_type: 'EMAIL' }]" |
| 43 })), 'Loaded invites different than requested invites'); |
| 44 |
| 45 chai.assert.ok(apiSpy.calledWith(sinon.match.any, sinon.match({ |
| 46 'widget_size': 72 |
| 47 })), 'Loaded width different than requested width'); |
| 48 } |
| 49 |
| 50 document.addEventListener('polymer-ready', function() { |
| 51 |
| 52 var hg = document.querySelector('google-hangout-button'); |
| 53 var apiSpy; |
| 54 |
| 55 // Set up Api spies. |
| 56 hg.addEventListener('google-hangout-button-pregame', function() { |
| 57 var yt = hg.shadowRoot.querySelector('google-plusone-api'); |
| 58 apiSpy = sinon.spy(yt.api.hangout, 'render'); |
| 59 }); |
| 60 |
| 61 hg.addEventListener('google-hangout-button-ready', function() { |
| 62 // Check if element's arguments are applied. |
| 63 testHangoutArgumentsAreApplied(hg, apiSpy); |
| 64 // Check if the hangout button iframe is created. |
| 65 testIframeCreated(hg); |
| 66 // Reset spies. |
| 67 apiSpy.reset(); |
| 68 done(); |
| 69 }); |
| 70 }); |
| 71 </script> |
| 72 </body> |
| 73 </html> |
OLD | NEW |