mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 14:12:43 +00:00
Add markModified mock function to test spec
This commit is contained in:
@@ -11,6 +11,7 @@ describe('Tests for api', ()=>{
|
|||||||
let modelBrew;
|
let modelBrew;
|
||||||
let saveFunc;
|
let saveFunc;
|
||||||
let removeFunc;
|
let removeFunc;
|
||||||
|
let markModifiedFunc;
|
||||||
let saved;
|
let saved;
|
||||||
|
|
||||||
beforeEach(()=>{
|
beforeEach(()=>{
|
||||||
@@ -20,12 +21,14 @@ describe('Tests for api', ()=>{
|
|||||||
return saved;
|
return saved;
|
||||||
});
|
});
|
||||||
removeFunc = jest.fn(async function() {});
|
removeFunc = jest.fn(async function() {});
|
||||||
|
markModifiedFunc = jest.fn(()=>true);
|
||||||
|
|
||||||
modelBrew = (brew)=>({
|
modelBrew = (brew)=>({
|
||||||
...brew,
|
...brew,
|
||||||
save : saveFunc,
|
save : saveFunc,
|
||||||
remove : removeFunc,
|
remove : removeFunc,
|
||||||
toObject : function() {
|
markModified : markModifiedFunc,
|
||||||
|
toObject : function() {
|
||||||
delete this.save;
|
delete this.save;
|
||||||
delete this.toObject;
|
delete this.toObject;
|
||||||
delete this.remove;
|
delete this.remove;
|
||||||
@@ -435,27 +438,28 @@ brew`);
|
|||||||
|
|
||||||
expect(res.status).toHaveBeenCalledWith(200);
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
expect(res.send).toHaveBeenCalledWith({
|
expect(res.send).toHaveBeenCalledWith({
|
||||||
_id : '1',
|
_id : '1',
|
||||||
authors : ['test user'],
|
authors : ['test user'],
|
||||||
createdAt : undefined,
|
createdAt : undefined,
|
||||||
description : '',
|
description : '',
|
||||||
editId : expect.any(String),
|
editId : expect.any(String),
|
||||||
gDrive : false,
|
gDrive : false,
|
||||||
pageCount : 1,
|
markModified : expect.any(Function),
|
||||||
published : false,
|
pageCount : 1,
|
||||||
renderer : 'V3',
|
published : false,
|
||||||
shareId : expect.any(String),
|
renderer : 'V3',
|
||||||
style : undefined,
|
shareId : expect.any(String),
|
||||||
systems : [],
|
style : undefined,
|
||||||
tags : [],
|
systems : [],
|
||||||
text : undefined,
|
tags : [],
|
||||||
textBin : expect.objectContaining({}),
|
text : undefined,
|
||||||
theme : '5ePHB',
|
textBin : expect.objectContaining({}),
|
||||||
thumbnail : '',
|
theme : '5ePHB',
|
||||||
title : 'asdf',
|
thumbnail : '',
|
||||||
trashed : false,
|
title : 'asdf',
|
||||||
updatedAt : undefined,
|
trashed : false,
|
||||||
views : 0
|
updatedAt : undefined,
|
||||||
|
views : 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -493,28 +497,29 @@ brew`);
|
|||||||
expect(google.newGoogleBrew).toHaveBeenCalled();
|
expect(google.newGoogleBrew).toHaveBeenCalled();
|
||||||
expect(res.status).toHaveBeenCalledWith(200);
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
expect(res.send).toHaveBeenCalledWith({
|
expect(res.send).toHaveBeenCalledWith({
|
||||||
_id : '1',
|
_id : '1',
|
||||||
authors : ['test user'],
|
authors : ['test user'],
|
||||||
createdAt : undefined,
|
createdAt : undefined,
|
||||||
description : '',
|
description : '',
|
||||||
editId : expect.any(String),
|
editId : expect.any(String),
|
||||||
gDrive : false,
|
gDrive : false,
|
||||||
pageCount : undefined,
|
pageCount : undefined,
|
||||||
published : false,
|
published : false,
|
||||||
renderer : undefined,
|
renderer : undefined,
|
||||||
shareId : expect.any(String),
|
shareId : expect.any(String),
|
||||||
googleId : expect.any(String),
|
googleId : expect.any(String),
|
||||||
style : undefined,
|
markModified : expect.any(Function),
|
||||||
systems : [],
|
style : undefined,
|
||||||
tags : [],
|
systems : [],
|
||||||
text : undefined,
|
tags : [],
|
||||||
textBin : undefined,
|
text : undefined,
|
||||||
theme : '5ePHB',
|
textBin : undefined,
|
||||||
thumbnail : '',
|
theme : '5ePHB',
|
||||||
title : 'asdf',
|
thumbnail : '',
|
||||||
trashed : false,
|
title : 'asdf',
|
||||||
updatedAt : undefined,
|
trashed : false,
|
||||||
views : 0
|
updatedAt : undefined,
|
||||||
|
views : 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -627,6 +632,7 @@ brew`);
|
|||||||
await api.deleteBrew(req, res);
|
await api.deleteBrew(req, res);
|
||||||
|
|
||||||
expect(api.getBrew).toHaveBeenCalled();
|
expect(api.getBrew).toHaveBeenCalled();
|
||||||
|
expect(markModifiedFunc).toHaveBeenCalled();
|
||||||
expect(model.findOne).toHaveBeenCalled();
|
expect(model.findOne).toHaveBeenCalled();
|
||||||
expect(removeFunc).not.toHaveBeenCalled();
|
expect(removeFunc).not.toHaveBeenCalled();
|
||||||
expect(saveFunc).toHaveBeenCalled();
|
expect(saveFunc).toHaveBeenCalled();
|
||||||
@@ -716,6 +722,7 @@ brew`);
|
|||||||
await api.deleteBrew(req, res);
|
await api.deleteBrew(req, res);
|
||||||
|
|
||||||
expect(api.getBrew).toHaveBeenCalled();
|
expect(api.getBrew).toHaveBeenCalled();
|
||||||
|
// expect(markModifiedFunc).toHaveBeenCalled();
|
||||||
expect(model.findOne).toHaveBeenCalled();
|
expect(model.findOne).toHaveBeenCalled();
|
||||||
expect(removeFunc).not.toHaveBeenCalled();
|
expect(removeFunc).not.toHaveBeenCalled();
|
||||||
expect(api.deleteGoogleBrew).toHaveBeenCalled();
|
expect(api.deleteGoogleBrew).toHaveBeenCalled();
|
||||||
|
|||||||
Reference in New Issue
Block a user