0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-15 23:32:41 +00:00
This commit is contained in:
Trevor Buckner
2024-07-28 18:03:25 -04:00
parent 88eaebfd49
commit 8221579b6a
5 changed files with 74 additions and 74 deletions

View File

@@ -589,13 +589,13 @@ brew`);
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew })); const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId])); model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
const req = { params: { renderer: "V3", id: "userThemeAID" }, get: () => { return 'localhost'; }, protocol: 'https' }; const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
await api.getThemeBundle(req, res); await api.getThemeBundle(req, res);
expect(res.status).toHaveBeenCalledWith(200); expect(res.status).toHaveBeenCalledWith(200);
expect(res.send).toHaveBeenCalledWith({ expect(res.send).toHaveBeenCalledWith({
styles: ["/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style"], styles : ['/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style'],
snippets : [] snippets : []
}); });
}); });
@@ -609,23 +609,23 @@ brew`);
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew })); const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId])); model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
const req = { params: { renderer: "V3", id: "userThemeAID" }, get: () => { return 'localhost'; }, protocol: 'https' }; const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
await api.getThemeBundle(req, res); await api.getThemeBundle(req, res);
expect(res.status).toHaveBeenCalledWith(200); expect(res.status).toHaveBeenCalledWith(200);
expect(res.send).toHaveBeenCalledWith({ expect(res.send).toHaveBeenCalledWith({
styles : [ styles : [
"/* From Brew: https://localhost/share/userThemeCID */\n\nUser Theme C Style", '/* From Brew: https://localhost/share/userThemeCID */\n\nUser Theme C Style',
"/* From Brew: https://localhost/share/userThemeBID */\n\nUser Theme B Style", '/* From Brew: https://localhost/share/userThemeBID */\n\nUser Theme B Style',
"/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style" '/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style'
], ],
snippets : [] snippets : []
}); });
}); });
it('should return Theme Bundle for a Static Theme', async ()=>{ it('should return Theme Bundle for a Static Theme', async ()=>{
const req = { params: { renderer: "V3", id: "5ePHB" }, get: () => { return 'localhost'; }, protocol: 'https' }; const req = { params: { renderer: 'V3', id: '5ePHB' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
await api.getThemeBundle(req, res); await api.getThemeBundle(req, res);
@@ -636,8 +636,8 @@ brew`);
`/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");` `/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`
], ],
snippets : [ snippets : [
"V3_Blank", 'V3_Blank',
"V3_5ePHB" 'V3_5ePHB'
] ]
}); });
}); });
@@ -651,7 +651,7 @@ brew`);
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew })); const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId])); model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
const req = { params: { renderer: "V3", id: "userThemeAID" }, get: () => { return 'localhost'; }, protocol: 'https' }; const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
await api.getThemeBundle(req, res); await api.getThemeBundle(req, res);
@@ -661,14 +661,14 @@ brew`);
`/* From Theme Blank */\n\n@import url("/themes/V3/Blank/style.css");`, `/* From Theme Blank */\n\n@import url("/themes/V3/Blank/style.css");`,
`/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`, `/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`,
`/* From Theme 5eDMG */\n\n@import url("/themes/V3/5eDMG/style.css");`, `/* From Theme 5eDMG */\n\n@import url("/themes/V3/5eDMG/style.css");`,
"/* From Brew: https://localhost/share/userThemeCID */\n\nUser Theme C Style", '/* From Brew: https://localhost/share/userThemeCID */\n\nUser Theme C Style',
"/* From Brew: https://localhost/share/userThemeBID */\n\nUser Theme B Style", '/* From Brew: https://localhost/share/userThemeBID */\n\nUser Theme B Style',
"/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style" '/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style'
], ],
snippets : [ snippets : [
"V3_Blank", 'V3_Blank',
"V3_5ePHB", 'V3_5ePHB',
"V3_5eDMG" 'V3_5eDMG'
] ]
}); });
}); });
@@ -680,18 +680,18 @@ brew`);
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew })); const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId])); model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
const req = { params: { renderer: "V3", id: "userThemeAID" }, get: () => { return 'localhost'; }, protocol: 'https' }; const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
let err let err;
await api.getThemeBundle(req, res) await api.getThemeBundle(req, res)
.catch(e => err = e); .catch((e)=>err = e);
expect(err).toEqual({ expect(err).toEqual({
HBErrorCode : "09", HBErrorCode : '09',
accessType : "share", accessType : 'share',
brewId : "missingTheme", brewId : 'missingTheme',
message : "Theme Not Found", message : 'Theme Not Found',
name : "ThemeLoad Error", name : 'ThemeLoad Error',
status : 404 }); status : 404 });
}); });
}); });