Skip to content

Commit

Permalink
Add test for locked brew
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ambatte committed Mar 17, 2024
1 parent 21c0916 commit 7f168f3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions server/homebrew.api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('Tests for api', ()=>{
id : '123456789012345678901234567890123abcdefghijkl'
}
});

expect(googleId).toEqual('123456789012345678901234567890123');
expect(id).toEqual('abcdefghijkl');
});
Expand All @@ -128,7 +128,7 @@ describe('Tests for api', ()=>{
id : '123456789012345678901234567890123abcdefghij'
}
});

expect(googleId).toEqual('123456789012345678901234567890123');
expect(id).toEqual('abcdefghij');
});
Expand Down Expand Up @@ -298,6 +298,18 @@ describe('Tests for api', ()=>{
expect(model.get).toHaveBeenCalledWith({ shareId: '1' });
expect(google.getGoogleBrew).toHaveBeenCalledWith('2', '1', 'share');
});

it('access is denied to a locked brew', async()=>{
const lockBrew = { title: 'test brew', shareId: '1', lock: { locked: true, code: 404, message: 'brew locked' } };
model.get = jest.fn(()=>toBrewPromise(lockBrew));
api.getId = jest.fn(()=>({ id: '1', googleId: undefined }));

const fn = api.getBrew('share', false);
const req = { brew: {} };
const next = jest.fn();

await expect(fn(req, null, next)).rejects.toEqual({ 'HBErrorCode': '100', 'brewId': '1', 'brewTitle': 'test brew', 'code': 404, 'message': 'brew locked' });
});
});

describe('mergeBrewText', ()=>{
Expand Down

0 comments on commit 7f168f3

Please sign in to comment.