mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 18:42:40 +00:00
Add test for missing meta:theme tag
This commit is contained in:
@@ -295,7 +295,7 @@ const api = {
|
|||||||
currentTheme = req.brew;
|
currentTheme = req.brew;
|
||||||
splitTextStyleAndMetadata(currentTheme);
|
splitTextStyleAndMetadata(currentTheme);
|
||||||
if(!currentTheme.tags.some(tag => tag === "meta:theme" || tag === "meta:Theme"))
|
if(!currentTheme.tags.some(tag => tag === "meta:theme" || tag === "meta:Theme"))
|
||||||
throw { brewId: req.params.id, name: 'Invalid Theme Selected', message: 'Selected theme does not have the meta:theme tag', HBErrorCode: '10' };
|
throw { brewId: req.params.id, name: 'Invalid Theme Selected', message: 'Selected theme does not have the meta:theme tag', status: 422, HBErrorCode: '10' };
|
||||||
themeName ??= currentTheme.title;
|
themeName ??= currentTheme.title;
|
||||||
themeAuthor ??= currentTheme.authors?.[0];
|
themeAuthor ??= currentTheme.authors?.[0];
|
||||||
|
|
||||||
|
|||||||
@@ -690,6 +690,27 @@ brew`);
|
|||||||
name : 'ThemeLoad Error',
|
name : 'ThemeLoad Error',
|
||||||
status : 404 });
|
status : 404 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fail for a User Theme not tagged with meta:theme', async ()=>{
|
||||||
|
const brews = {
|
||||||
|
userThemeAID : { title: 'User Theme A', renderer: 'V3', theme: null, shareId: 'userThemeAID', style: 'User Theme A Style' }
|
||||||
|
};
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
|
||||||
|
const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
|
||||||
|
|
||||||
|
let err;
|
||||||
|
await api.getThemeBundle(req, res)
|
||||||
|
.catch((e)=>err = e);
|
||||||
|
|
||||||
|
expect(err).toEqual({
|
||||||
|
HBErrorCode : '10',
|
||||||
|
brewId : 'userThemeAID',
|
||||||
|
message : 'Selected theme does not have the meta:theme tag',
|
||||||
|
name : 'Invalid Theme Selected',
|
||||||
|
status : 422 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteBrew', ()=>{
|
describe('deleteBrew', ()=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user