dimanche 31 juillet 2016

How to mock a publication in Meteor test

I'm using practicalmeteor/mocha package. Here I'm trying to test a subscription on a server side, but I cannot call the Publication. Can you guys suggest me a solution for this or a package to mock Publication. Below is the code that I write:

describe('Subscriptions test', () => { const userId = Random.id(); let sandbox;

    beforeEach((done) => {
      StubCollections.stub(PPDM_UNIT_CONVERSION);
      PPDM_UNIT_CONVERSION.insert({ FACTOR_NUMERATOR: 3.5 });
        sandbox = sinon.sandbox.create();
      done();
    })

    afterEach(() => {
      StubCollections.restore();
        sandbox.restore();
    })

    it('integration test - "core_exchange_rates" -  subscription', (done) => {
      const subs = Meteor.subscribe("core_exchange_rates", new Date(), 'RM');
        expect.(PPDM_UNIT_CONVERSION.findOne).to.be.above(0)
    });
});

Aucun commentaire:

Enregistrer un commentaire