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

Side by Side Diff: lib/src/firebase-element/test/test-helpers.html

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 1 month 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/src/firebase-element/test/firebase-collection.html ('k') | lib/src/firebase/firebase.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <link rel="import" href="../../promise-polyfill/promise-polyfill.html">
1 <script> 2 <script>
3 var firebaseTestProject = 'fb-element-demo';
4
2 function randomKey() { 5 function randomKey() {
3 return (0|(Math.random() * 999999999)).toString(); 6 return (0|(Math.random() * 999999999)).toString();
4 } 7 }
5 8
9 function randomInt(min, max) {
10 min = min || 0;
11 max = max || 10000;
12
13 return Math.floor(Math.random() * (max - min)) + min;
14 }
15
16 function randomObject(min, max) {
17 return {
18 value: randomInt(min, max)
19 };
20 }
21
6 function waitForEvent(element, event) { 22 function waitForEvent(element, event) {
7 return new Promise(function(resolve, reject) { 23 return new Promise(function(resolve, reject) {
8 element.addEventListener(event, function onEvent() { 24 element.addEventListener(event, function onEvent() {
25 window.clearTimeout(timeout);
9 element.removeEventListener(event, onEvent); 26 element.removeEventListener(event, onEvent);
10 resolve(); 27 resolve();
11 }); 28 });
29
30 var timeout = window.setTimeout(function() {
31 reject(new Error('Firebase response took more than 5 seconds.'));
32 }, 5000);
12 }); 33 });
13 } 34 }
35
36 function firebaseUrl(project, path) {
37 return 'https://' + project + '.firebaseio.com' + (path ? '/' + path : '');
38 }
39
40 function fixtureLocation(data) {
41 var firebase = new Firebase(firebaseUrl(firebaseTestProject));
42 return firebaseUrl(
43 firebaseTestProject,
44 firebase.push(data || {}).key()
45 );
46 }
47
48 function removeLocation(location) {
49 (new Firebase(location)).remove();
50 }
51
52 function fixtureFirebase(fixtureName, data) {
53 var firebase = fixture(fixtureName);
54 firebase.location = fixtureLocation(data);
55 return firebase;
56 }
57
58 function removeFirebase(firebase) {
59 removeLocation(firebase.location);
60 firebase.disconnect();
61 }
62
63 function arrayOfPrimitives(length) {
64 var array = [];
65
66 for (var i = 0; i < length; ++i) {
67 array.push(randomInt());
68 }
69
70 return array;
71 }
72
73 function arrayOfObjects(length) {
74 var array = [];
75
76 for (var i = 0; i < length; ++i) {
77 array.push(randomObject());
78 }
79
80 return array;
81 }
14 </script> 82 </script>
OLDNEW
« no previous file with comments | « lib/src/firebase-element/test/firebase-collection.html ('k') | lib/src/firebase/firebase.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698