{"size": 660, "ext": "js", "max_stars_repo_path": "email.js", "max_stars_repo_name": "Pushplaybang/meteor-email-stubs-redux", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "email.js", "max_issues_repo_name": "Pushplaybang/meteor-email-stubs-redux", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "email.js", "max_forks_repo_name": "Pushplaybang/meteor-email-stubs-redux", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.5714285714, "max_line_length": 89, "alphanum_fraction": 0.6727272727}
import { Meteor } from 'meteor/meteor';
import { Email } from 'meteor/email';

const emailStub = {
  collection: new Map(),
  stub() {
    Email.__send = Email.send;
    Email.send = options => emailStub.collection.set(emailStub.collection.size, options);
  },
  restore() {
    Email.send = Email.__send;
  },
  reset() {
    return emailStub.collection.clear();
  },
  getEmails() {
    return Array.from(emailStub.collection.values());
  },
};

// register methods with DDP
Meteor.methods({
  'emailStub/stub': emailStub.stub,
  'emailStub/restore': emailStub.restore,
  'emailStub/reset': emailStub.reset,
  'emailStub/getEmails': emailStub.getEmails,
});
