mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Minor changes, added example classes test
This commit is contained in:
parent
8801bb96cd
commit
d8b0c28471
4 changed files with 35 additions and 10 deletions
|
@ -19,8 +19,7 @@
|
|||
"nextdir": "nextStatic/qminingPagePublic",
|
||||
"name": "qmining",
|
||||
"urls": [
|
||||
"qmining.frylabs.net",
|
||||
"localhost"
|
||||
"qmining.frylabs.net"
|
||||
],
|
||||
"isNextJs": true
|
||||
},
|
||||
|
@ -31,7 +30,8 @@
|
|||
],
|
||||
"name": "api",
|
||||
"urls": [
|
||||
"api.frylabs.net"
|
||||
"api.frylabs.net",
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
"main": {
|
||||
|
|
|
@ -12,7 +12,6 @@ function setup(data: SubmoduleData): void {
|
|||
const publicDir = publicdirs[0]
|
||||
|
||||
const userFilesDir = publicDir + 'userFiles'
|
||||
|
||||
if (!utils.FileExists(userFilesDir)) {
|
||||
utils.CreatePath(userFilesDir, true)
|
||||
}
|
||||
|
@ -20,6 +19,10 @@ function setup(data: SubmoduleData): void {
|
|||
app.get('/listUserDir', (req: Request, res) => {
|
||||
logger.LogReq(req)
|
||||
|
||||
if (!utils.FileExists(userFilesDir)) {
|
||||
utils.CreatePath(userFilesDir, true)
|
||||
}
|
||||
|
||||
const subdir: any = req.query.subdir
|
||||
|
||||
if (subdir) {
|
||||
|
@ -168,7 +171,7 @@ function setup(data: SubmoduleData): void {
|
|||
}
|
||||
|
||||
utils
|
||||
.uploadFile(req, userFilesDir + '/' + safeDir)
|
||||
.uploadFile(req, userFilesDir + '/' + safeDir, true)
|
||||
.then((body) => {
|
||||
logger.Log(
|
||||
`Successfull upload ${body.filePath}`,
|
||||
|
|
25
src/utils/classes.test.ts
Normal file
25
src/utils/classes.test.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { compareString } from './classes'
|
||||
|
||||
const testCases: Array<{ s1: string; s2: string; res: number }> = [
|
||||
{ s1: 'hello', s2: 'hello', res: 100 },
|
||||
{ s1: 'aaaaa', s2: 'bbbbb', res: 0 },
|
||||
{
|
||||
s1: 'Mely állítás nem igaz a tőzsdékre?',
|
||||
s2: 'Mely állítás nem igaz a tőzsdékre?',
|
||||
res: 100,
|
||||
},
|
||||
{
|
||||
s1: 'Mely állítás nem igaz a tőzsdékre?',
|
||||
s2: 'Ez egy teljesen más mondat',
|
||||
res: 0,
|
||||
},
|
||||
{ s1: 'cHar caSe tESt', s2: 'ChaR cAse TEst', res: 0 },
|
||||
]
|
||||
|
||||
testCases.forEach((currCase) => {
|
||||
const { s1, s2, res } = currCase
|
||||
|
||||
test(`String compare tests: "${s1}" & "${s2}" should be: ${res}%`, () => {
|
||||
expect(compareString(s1, s1.split(' '), s2, s2.split(' '))).toBe(res)
|
||||
})
|
||||
})
|
|
@ -65,10 +65,7 @@ function getSubjNameWithoutYear(subjName: string): string {
|
|||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
function simplifyString(toremove) {
|
||||
return toremove
|
||||
.replace(/\s/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.toLowerCase()
|
||||
return toremove.replace(/\s/g, ' ').replace(/\s+/g, ' ').toLowerCase()
|
||||
}
|
||||
|
||||
function removeStuff(
|
||||
|
@ -92,7 +89,7 @@ function removeUnnecesarySpaces(toremove: string) {
|
|||
return normalizeSpaces(toremove).replace(/\s+/g, ' ')
|
||||
}
|
||||
|
||||
function compareString(
|
||||
export function compareString(
|
||||
s1: string,
|
||||
s1a: Array<string>,
|
||||
s2: string,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue