Changing how generateRandomString() is implemented to reduce number of failed tests

Tests were failing due to generateRandomString() sometimes returning a
string with a “.” in it (which is invalid in Firebase”).
This commit is contained in:
jacobawenger
2014-06-29 16:16:18 -07:00
parent 2db4ceae3b
commit 3d2848d611
2 changed files with 10 additions and 2 deletions

View File

@@ -94,4 +94,4 @@ $ gulp watch # watch for source file changes
`gulp watch` will watch for changes in the `/src/` directory and lint, concatenate, and minify the source files when a change occurs. The output files - `reactfire.js` and `reactfire.min.js` - are written to the `/dist/` directory.
You can run the test suite by navigating to `file:///path/to/tests/TestRunner.html` or run the tests via the command line using `gulp test`.
You can run the test suite by navigating to `file:///path/to/reactfire/tests/TestRunner.html` or via the command line using `gulp test`.

View File

@@ -39,7 +39,15 @@ function afterEachHelper(done) {
/* Returns a random alphabetic string of variable length */
function generateRandomString() {
return (Math.random() + 1).toString(36).substring(7);
var possibleCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var numPossibleCharacters = possibleCharacters.length;
var text = "";
for (var i = 0; i < 10; i++) {
text += possibleCharacters.charAt(Math.floor(Math.random() * numPossibleCharacters));
}
return text;
}
/* Returns the current data in the Firebase */