Upgrading from v5 to v6 breaks create function
Closed this issue · 2 comments
Nokel81 commented
In version v5.4.1 I would write this to make a test:
function createDefaultImages(num) {
var images = [];
for (var i = 0; i < num; i++) {
images.push(createDefaultImage(i));
}
DataAccess.__set__("odataToMongoParser", odataToMongoStub);
return images;
}
function createDefaultImage(num) {
var image = new ImageData();
image.Filename = "name" + num + ".png";
image.MLSRegion = "R" + num;
image.Company = "C" + num;
image.ListingId = "123456" + num;
image.Location = "/kkk/lll/aaa/sss/";
return image;
}
beforeEach(function (done) {
dataAccess = new DataAccess({db:{host:"test"}});
dataAccess.connect();
var images = createDefaultImages(3);
imageIds = [];
images.forEach(function (i) {
imageIds.push(i._id);
});
ImageData.create(images, function (err) {
done(err);
});
});
afterEach(function (done) {
mockgoose.reset(function () {
done();
});
});
after(function (done) {
mongoose.unmock(function () {
done();
});
});
it('should return all images', function (done) {
odataToMongoStub.yields(undefined, {});
dataAccess.query({}, function (err, data) {
data.length.should.equal(imageIds.length);
done();
});
});
However, upgrading to v6.0.2 breaks this as I get the error Ensure that done() is being called in 'beforeEach' hook
. It seems like the .create() function is not calling the callback in the latest version
petershaw commented
It doesn not work with the docs ecample
var Mongoose = require('mongoose').Mongoose;
var mongoose = new Mongoose();
var mockgoose = require('mockgoose');
But i get recent results with
var mongoose = require('mongoose');
var mockgoose = require('mockgoose');
mockgoose(mongoose).then(function() {
mongoose.connect('...
I will take a look deeper into it.
winfinit commented
Hello, I am not monitoring this project anymore, please resubmit it under mockgoose/mockgoose if this is still an issue with new 7.x release