{"size": 946, "ext": "js", "max_stars_repo_path": "7-assets/past-student-repos/Server-Testing-master/model.test.js", "max_stars_repo_name": "eengineergz/Lambda", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "7-assets/past-student-repos/Server-Testing-master/model.test.js", "max_issues_repo_name": "eengineergz/Lambda", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "7-assets/past-student-repos/Server-Testing-master/model.test.js", "max_forks_repo_name": "eengineergz/Lambda", "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.65, "max_line_length": 71, "alphanum_fraction": 0.5581395349}
const chai = require('chai');
const { expect } = chai;
const sinon = require('sinon');

const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/data', { useMongoClient: true });

const Food = require('./food');

describe('Food', () => {
  beforeEach(done => {
    sinon.stub(Food, 'find');
    done();
  });

  afterEach(done => {
    Food.find.restore();
    done();
  });

  describe('getName()', () => {
    it('should return the name of the food item', done => {
      const food = new Food({ name: 'Minestrone' });
      expect(food.getName()).to.equal('Minestrone');
      done();
    });
  });

  describe('getFoods()', () => {
    it('should return all the foods', done => {
      Food.find.yields(null, [{ name: 'Fettuccine Alfredo' }]);
      Food.getFoods(foods => {
        expect(foods.length).to.equal(1);
        expect(foods[0].name).to.equal('Fettuccine Alfredo');
        done();
      });
    });
  });
});
