mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 19:22:52 +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,11 +21,13 @@ 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,
|
||||||
|
markModified : markModifiedFunc,
|
||||||
toObject : function() {
|
toObject : function() {
|
||||||
delete this.save;
|
delete this.save;
|
||||||
delete this.toObject;
|
delete this.toObject;
|
||||||
@@ -441,6 +444,7 @@ brew`);
|
|||||||
description : '',
|
description : '',
|
||||||
editId : expect.any(String),
|
editId : expect.any(String),
|
||||||
gDrive : false,
|
gDrive : false,
|
||||||
|
markModified : expect.any(Function),
|
||||||
pageCount : 1,
|
pageCount : 1,
|
||||||
published : false,
|
published : false,
|
||||||
renderer : 'V3',
|
renderer : 'V3',
|
||||||
@@ -504,6 +508,7 @@ brew`);
|
|||||||
renderer : undefined,
|
renderer : undefined,
|
||||||
shareId : expect.any(String),
|
shareId : expect.any(String),
|
||||||
googleId : expect.any(String),
|
googleId : expect.any(String),
|
||||||
|
markModified : expect.any(Function),
|
||||||
style : undefined,
|
style : undefined,
|
||||||
systems : [],
|
systems : [],
|
||||||
tags : [],
|
tags : [],
|
||||||
@@ -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