Meteor-Community-Packages / meteor-publication-collector

Test a Meteor publication by collecting its output.
https://atmospherejs.com/johanbrook/publication-collector
MIT License
33 stars 20 forks source link

Use universal_publish_handlers when no publication-name is given #32

Open jankapunkt opened 7 years ago

jankapunkt commented 7 years ago

I want to test (server side) a package, that auto-publishes data to the user. The publication scheme it uses therefore is

Metepr.publish(null, function(){...})

which adds the publication to the universal_publish_handlers instead of publish_handlers, as taken from the code.

When calling the collector.collect(null, ...); then of course I get an error, because it uses publish_handlers[name] and not universal_publish_handlers when no name is provided.

Does it make sense to add this feature? I could try to provide a PR with an implementation and some tests, if desired.

johanbrook commented 6 years ago

Hey! So sorry for late response.

If this is still a problem for you, feel free to submit a PR!

BarrySaidy commented 5 years ago

hello, brook's I am having an issue with my publication test. it's returning an empty array.

  describe('companyOrders.all', function() {
    it('gets all the companyOrders available', function(done) {
      const collector = new PublicationCollector({ userId: Random.id() });
      collector.collect('companyOrders.all', function(collections) {
        chai.assert.equal(collections.CompanyOrders.length, 5);
        done();
      });
    });
  });