mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-21 11:32:47 +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 saveFunc;
|
||||
let removeFunc;
|
||||
let markModifiedFunc;
|
||||
let saved;
|
||||
|
||||
beforeEach(()=>{
|
||||
@@ -20,11 +21,13 @@ describe('Tests for api', ()=>{
|
||||
return saved;
|
||||
});
|
||||
removeFunc = jest.fn(async function() {});
|
||||
markModifiedFunc = jest.fn(()=>true);
|
||||
|
||||
modelBrew = (brew)=>({
|
||||
...brew,
|
||||
save : saveFunc,
|
||||
remove : removeFunc,
|
||||
markModified : markModifiedFunc,
|
||||
toObject : function() {
|
||||
delete this.save;
|
||||
delete this.toObject;
|
||||
@@ -441,6 +444,7 @@ brew`);
|
||||
description : '',
|
||||
editId : expect.any(String),
|
||||
gDrive : false,
|
||||
markModified : expect.any(Function),
|
||||
pageCount : 1,
|
||||
published : false,
|
||||
renderer : 'V3',
|
||||
@@ -504,6 +508,7 @@ brew`);
|
||||
renderer : undefined,
|
||||
shareId : expect.any(String),
|
||||
googleId : expect.any(String),
|
||||
markModified : expect.any(Function),
|
||||
style : undefined,
|
||||
systems : [],
|
||||
tags : [],
|
||||
@@ -627,6 +632,7 @@ brew`);
|
||||
await api.deleteBrew(req, res);
|
||||
|
||||
expect(api.getBrew).toHaveBeenCalled();
|
||||
expect(markModifiedFunc).toHaveBeenCalled();
|
||||
expect(model.findOne).toHaveBeenCalled();
|
||||
expect(removeFunc).not.toHaveBeenCalled();
|
||||
expect(saveFunc).toHaveBeenCalled();
|
||||
@@ -716,6 +722,7 @@ brew`);
|
||||
await api.deleteBrew(req, res);
|
||||
|
||||
expect(api.getBrew).toHaveBeenCalled();
|
||||
// expect(markModifiedFunc).toHaveBeenCalled();
|
||||
expect(model.findOne).toHaveBeenCalled();
|
||||
expect(removeFunc).not.toHaveBeenCalled();
|
||||
expect(api.deleteGoogleBrew).toHaveBeenCalled();
|
||||
|
||||
Reference in New Issue
Block a user