0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

Fix remaining jest issues

This commit is contained in:
David Bolack
2024-03-06 23:27:43 -06:00
parent eb4ecf853b
commit e487f9a951
4 changed files with 425 additions and 542 deletions

922
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -80,9 +80,9 @@
]
},
"dependencies": {
"@babel/core": "^7.24.0",
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/core": "^7.23.9",
"@babel/plugin-transform-runtime": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-react": "^7.23.3",
"@googleapis/drive": "^8.7.0",
"body-parser": "^1.20.2",
@@ -92,7 +92,7 @@
"create-react-class": "^15.7.0",
"dedent-tabs": "^0.10.3",
"expr-eval": "^2.0.2",
"express": "^4.18.3",
"express": "^4.18.2",
"express-async-handler": "^1.2.0",
"express-static-gzip": "2.1.7",
"fs-extra": "11.2.0",
@@ -106,13 +106,13 @@
"marked-smartypants-lite": "^1.0.2",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.30.1",
"mongoose": "^8.2.1",
"mongoose": "^8.2.0",
"nanoid": "3.3.4",
"nconf": "^0.12.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-frame-component": "^4.1.3",
"react-router-dom": "6.22.2",
"react-router-dom": "6.22.1",
"sanitize-filename": "1.6.3",
"superagent": "^8.1.2",
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
@@ -120,7 +120,7 @@
"devDependencies": {
"eslint": "^8.57.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react": "^7.33.2",
"jest": "^29.7.0",
"jest-expect-message": "^1.1.3",
"postcss-less": "^6.0.0",

View File

@@ -9,6 +9,7 @@ const yaml = require('js-yaml');
const asyncHandler = require('express-async-handler');
const { nanoid } = require('nanoid');
const { DEFAULT_BREW, DEFAULT_BREW_LOAD } = require('./brewDefaults.js');
const themes = require('../themes/themes.json');
@@ -66,7 +67,7 @@ const api = {
}
return { id, googleId };
},
getUsersBrewThemes : async (username, id, req, res, next)=>{
getUsersBrewThemes : async (username, id)=>{
const fields = [
'title',
'tags',
@@ -84,16 +85,19 @@ const api = {
const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['theme', 'Theme', 'type:theme', 'type:Theme'] }, editId: { $ne: id } });
for await (const brew of brews) {
userThemes.Brew[`#${brew.editId}`] = {
name : brew.title,
renderer : 'V3',
baseTheme : '',
baseSnippets : false,
path : `#${brew.editId}`,
thumbnail : brew.thumbnail.length > 0 ? brew.thumbnail : '/assets/naturalCritLogoWhite.svg'
};
if(brews) {
for await (const brew of brews) {
userThemes.Brew[`#${brew.editId}`] = {
name : brew.title,
renderer : 'V3',
baseTheme : '',
baseSnippets : false,
path : `#${brew.editId}`,
thumbnail : brew.thumbnail.length > 0 ? brew.thumbnail : '/assets/naturalCritLogoWhite.svg'
};
}
}
return userThemes;
},
getBrew : (accessType, stubOnly = false)=>{

View File

@@ -287,6 +287,9 @@ describe('Tests for api', ()=>{
thumbnail : '',
textBin : undefined,
version : undefined,
userThemes : {
Brew: {}
},
createdAt : undefined,
gDrive : false,
style : undefined,
@@ -581,7 +584,7 @@ brew`);
api.getBrewThemeWithCSS(req, res);
const sent = res.send.mock.calls[0][0];
expect(sent).toBe(`// From Theme: test brew\n\n@import /api/css/V3/5ePHB/styles.css\n\nI Have a style!`);
expect(sent).toBe(`@import url("/css/V3/5ePHB");\n\n/* From Brew: test brew*/\n\nI Have a style!`);
expect(res.status).toHaveBeenCalledWith(200);
});
});
@@ -597,7 +600,7 @@ brew`);
api.getBrewThemeWithCSS(req, res);
const sent = res.send.mock.calls[0][0];
expect(sent).toBe(`// From Theme: test brew\n\n@import /api/css/IamATheme\n\nI Have a style!`);
expect(sent).toBe(`@import url("/css/IamATheme");\n\n/* From Brew: test brew*/\n\nI Have a style!`);
expect(res.status).toHaveBeenCalledWith(200);
});
});