mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 10:12:41 +00:00
Merge branch 'master' into dependabot/npm_and_yarn/stylistic/stylelint-plugin-4.0.0
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
&::before {
|
&::before {
|
||||||
margin-right : 5px;
|
margin-right : 5px;
|
||||||
font-family : 'Font Awesome 6 Free';
|
font-family : 'Font Awesome 6 Free';
|
||||||
|
font-weight : 900;
|
||||||
content : '\f00c';
|
content : '\f00c';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
74
client/homebrew/utils/request-middleware.spec.js
Normal file
74
client/homebrew/utils/request-middleware.spec.js
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import requestMiddleware from './request-middleware';
|
||||||
|
|
||||||
|
jest.mock('superagent');
|
||||||
|
import request from 'superagent';
|
||||||
|
|
||||||
|
describe('request-middleware', ()=>{
|
||||||
|
let version;
|
||||||
|
|
||||||
|
let setFn;
|
||||||
|
let testFn;
|
||||||
|
|
||||||
|
beforeEach(()=>{
|
||||||
|
jest.resetAllMocks();
|
||||||
|
version = global.version;
|
||||||
|
|
||||||
|
global.version = '999';
|
||||||
|
|
||||||
|
setFn = jest.fn();
|
||||||
|
testFn = jest.fn(()=>{ return { set: setFn }; });
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(()=>{
|
||||||
|
global.version = version;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add header to get', ()=>{
|
||||||
|
// Ensure tests functions have been reset
|
||||||
|
expect(testFn).not.toHaveBeenCalled();
|
||||||
|
expect(setFn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
request.get = testFn;
|
||||||
|
|
||||||
|
requestMiddleware.get('path');
|
||||||
|
|
||||||
|
expect(testFn).toHaveBeenCalledWith('path');
|
||||||
|
expect(setFn).toHaveBeenCalledWith('Homebrewery-Version', '999');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add header to put', ()=>{
|
||||||
|
expect(testFn).not.toHaveBeenCalled();
|
||||||
|
expect(setFn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
request.put = testFn;
|
||||||
|
|
||||||
|
requestMiddleware.put('path');
|
||||||
|
|
||||||
|
expect(testFn).toHaveBeenCalledWith('path');
|
||||||
|
expect(setFn).toHaveBeenCalledWith('Homebrewery-Version', '999');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add header to post', ()=>{
|
||||||
|
expect(testFn).not.toHaveBeenCalled();
|
||||||
|
expect(setFn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
request.post = testFn;
|
||||||
|
|
||||||
|
requestMiddleware.post('path');
|
||||||
|
|
||||||
|
expect(testFn).toHaveBeenCalledWith('path');
|
||||||
|
expect(setFn).toHaveBeenCalledWith('Homebrewery-Version', '999');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add header to delete', ()=>{
|
||||||
|
expect(testFn).not.toHaveBeenCalled();
|
||||||
|
expect(setFn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
request.delete = testFn;
|
||||||
|
|
||||||
|
requestMiddleware.delete('path');
|
||||||
|
|
||||||
|
expect(testFn).toHaveBeenCalledWith('path');
|
||||||
|
expect(setFn).toHaveBeenCalledWith('Homebrewery-Version', '999');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -487,8 +487,8 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
|
|||||||
const query = { authors: req.account.username, googleId: { $exists: false } };
|
const query = { authors: req.account.username, googleId: { $exists: false } };
|
||||||
const mongoCount = await HomebrewModel.countDocuments(query)
|
const mongoCount = await HomebrewModel.countDocuments(query)
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
mongoCount = 0;
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
data.accountDetails = {
|
data.accountDetails = {
|
||||||
|
|||||||
Reference in New Issue
Block a user