// Tests for the links publications
//
// https://guide.meteor.com/testing.html

import { assert } from 'chai';
import { Links } from './links.js';
import { PublicationCollector } from 'meteor/communitypackages:publication-collector';
import './publications.js';

if (Meteor.isServer) {
  describe('links publications', function() {
    beforeEach(async function() {
      await Links.removeAsync({});
      await Links.insertAsync({
        title: 'meteor homepage',
        url: 'https://www.meteor.com',
      });
    });

    describe('links.all', function() {
      it('sends all links', function(done) {
        const collector = new PublicationCollector();
        collector.collect('links.all', (collections) => {
          assert.equal(collections.links.length, 1);
          done();
        });
      });
    });
  });
}
