From 3d2848d611bb4a295ae95591c276db8d52ceb4b0 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Sun, 29 Jun 2014 16:16:18 -0700 Subject: [PATCH] Changing how generateRandomString() is implemented to reduce number of failed tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests were failing due to generateRandomString() sometimes returning a string with a “.” in it (which is invalid in Firebase”). --- README.md | 2 +- tests/specs/common.spec.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a8da63..34d898e 100644 --- a/README.md +++ b/README.md @@ -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`. \ No newline at end of file +You can run the test suite by navigating to `file:///path/to/reactfire/tests/TestRunner.html` or via the command line using `gulp test`. \ No newline at end of file diff --git a/tests/specs/common.spec.js b/tests/specs/common.spec.js index 79263ab..e335c9c 100644 --- a/tests/specs/common.spec.js +++ b/tests/specs/common.spec.js @@ -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 */