Skip to content

Commit 640abe2

Browse files
committed
fix snapshot.forEach() in MockFirebase, clean up old mock file
1 parent 23e0f07 commit 640abe2

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

tests/firebase-mock.js

-20
This file was deleted.

tests/lib/MockFirebase.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// some hoop jumping for node require() vs browser usage
44
var exports = typeof exports != 'undefined' ? exports : this;
55
var _, sinon;
6-
exports.Firebase = MockFirebase; //todo use MockFirebase.stub() instead of forcing overwrite
6+
exports.Firebase = MockFirebase; //todo use MockFirebase.stub() instead of forcing overwrite of window.Firebase
77
if( typeof module !== "undefined" && module.exports && typeof(require) === 'function' ) {
88
_ = require('lodash');
99
sinon = require('sinon');
@@ -19,7 +19,9 @@
1919
* ## Setup
2020
*
2121
* // in windows
22-
* MockFirebase.stub(window, 'Firebase'); // replace window.Firebase
22+
* <script src="lib/lodash.js"></script> <!-- dependency -->
23+
* <script src="lib/MockFirebase.js"></script> <!-- the lib -->
24+
* <!-- not working yet: MockFirebase.stub(window, 'Firebase'); // replace window.Firebase -->
2325
*
2426
* // in node.js
2527
* var Firebase = require('../lib/MockFirebase');
@@ -42,8 +44,8 @@
4244
* ## Trigger events automagically instead of calling flush()
4345
*
4446
* var fb = new MockFirebase('Mock://hello/world');
45-
* fb.autoFlush(1000); // triggers events after 1 second
46-
* fb.autoFlush(); // triggers events immediately
47+
* fb.autoFlush(1000); // triggers events after 1 second (asynchronous)
48+
* fb.autoFlush(); // triggers events immediately (synchronous)
4749
*
4850
* ## Simulating Errors
4951
*
@@ -281,6 +283,7 @@
281283
* @param {Function} [callback]
282284
*/
283285
auth: function(token, callback) {
286+
//todo invoke callback with the parsed token contents
284287
callback && this._defer(callback);
285288
},
286289

@@ -375,7 +378,7 @@
375378
getPriority: function() { return null; }, //todo
376379
forEach: function(cb, scope) {
377380
_.each(data, function(v, k, list) {
378-
var res = cb.call(scope, v, k, list);
381+
var res = cb.call(scope, makeSnap(ref.child(k), v));
379382
return !(res === true);
380383
});
381384
}

0 commit comments

Comments
 (0)