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

Unified 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, 2 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/firebase-element/test/test-helpers.html
diff --git a/lib/src/firebase-element/test/test-helpers.html b/lib/src/firebase-element/test/test-helpers.html
index bfd28b074d885932ddf90170f7937b1212af453d..735137b2777c98c304c12d931f508e3ff9c59097 100644
--- a/lib/src/firebase-element/test/test-helpers.html
+++ b/lib/src/firebase-element/test/test-helpers.html
@@ -1,14 +1,82 @@
+<link rel="import" href="../../promise-polyfill/promise-polyfill.html">
<script>
+ var firebaseTestProject = 'fb-element-demo';
+
function randomKey() {
return (0|(Math.random() * 999999999)).toString();
}
+ function randomInt(min, max) {
+ min = min || 0;
+ max = max || 10000;
+
+ return Math.floor(Math.random() * (max - min)) + min;
+ }
+
+ function randomObject(min, max) {
+ return {
+ value: randomInt(min, max)
+ };
+ }
+
function waitForEvent(element, event) {
return new Promise(function(resolve, reject) {
element.addEventListener(event, function onEvent() {
+ window.clearTimeout(timeout);
element.removeEventListener(event, onEvent);
resolve();
});
+
+ var timeout = window.setTimeout(function() {
+ reject(new Error('Firebase response took more than 5 seconds.'));
+ }, 5000);
});
}
+
+ function firebaseUrl(project, path) {
+ return 'https://' + project + '.firebaseio.com' + (path ? '/' + path : '');
+ }
+
+ function fixtureLocation(data) {
+ var firebase = new Firebase(firebaseUrl(firebaseTestProject));
+ return firebaseUrl(
+ firebaseTestProject,
+ firebase.push(data || {}).key()
+ );
+ }
+
+ function removeLocation(location) {
+ (new Firebase(location)).remove();
+ }
+
+ function fixtureFirebase(fixtureName, data) {
+ var firebase = fixture(fixtureName);
+ firebase.location = fixtureLocation(data);
+ return firebase;
+ }
+
+ function removeFirebase(firebase) {
+ removeLocation(firebase.location);
+ firebase.disconnect();
+ }
+
+ function arrayOfPrimitives(length) {
+ var array = [];
+
+ for (var i = 0; i < length; ++i) {
+ array.push(randomInt());
+ }
+
+ return array;
+ }
+
+ function arrayOfObjects(length) {
+ var array = [];
+
+ for (var i = 0; i < length; ++i) {
+ array.push(randomObject());
+ }
+
+ return array;
+ }
</script>
« 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