Skip to content

chetbox/firebase-mock-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

firebase-mock-functions

Test your Firebase database triggers offline

Installation

npm install --save-dev firebase-mock-functions

Example usage

var chai = require('chai');
chai.use(require('chai-as-promised'));

var FakeDatabase = require('firebase-mock-functions');
var functions = require('firebase-functions');
var admin = require('firebase-admin');
var db = new FakeDatabase(functions, admin);
db.override();
db.database.autoFlush(true);

// Your Firebase functions "index.js".
// This contains a function which sums /items values and saves to /total
var index = require('index');

db.setFunctionsModule(index);

describe('count total', function() {

  beforeEach(function() {
    return db.setWithoutTriggers('/', { items: { one: 1, two: 2}, total: 3 });
  });

  it('updates "/total" when a new item is added', function() {
    return db.write('/items/three', 3)
    .then(function() { return db.value('/total') })
    .should.eventually.equal(6);
  });

});

About

Test Firebase database triggers with a mock database

Resources

License

Stars

Watchers

Forks

Packages

No packages published