Google Cloud Functions: How to stub firebase queue for Unit Tests?

299 Views Asked by At
//index.js
const functions = require('firebase-functions');
var Queue = require('firebase-queue');

var specQueue = new Queue();

//test.js
var assert = require('assert');
var sinon = require('sinon');
describe('test', function() {
  var Queue, firebaseQueueStub;

  before(() => {
    Queue =  require('firebase-queue');
    firebaseQueueStub = sinon.createStubInstance(Queue);
    myFunctions = require('../index');
  });

  describe('CREATED', function() {
      it('should return -1 when the value is not present', function() {
            assert.equal(-1, [1,5,3].indexOf(4));
          });
    });
});

How does one stub the firebase queue constructor in index.js? I've tried the above but firebase-queue is still being called instead of my stub. Thanks.

0

There are 0 best solutions below