removed submodule

This commit is contained in:
2023-12-21 16:50:58 -05:00
207 changed files with 30648 additions and 4 deletions

52
webui/tests/testlang.js Normal file
View File

@@ -0,0 +1,52 @@
async function loadLang(lang_id) {
let language_module
const result = []
try {
language_module = await import(`../src/lang/${lang_id}.mjs`)
language_module = language_module.default
} catch (e) {
language_module = {}
}
function parseObject(obj, root = '') {
for (const [key, value] of Object.entries(obj)) {
if (typeof value === 'string') {
result.push(root + key)
} else {
parseObject(value, root + key + '.')
}
}
}
parseObject(language_module)
return result
}
async function testLang(lang_id) {
const baseLangFile = await loadLang('en')
const comparedLangFile = await loadLang(lang_id)
if (comparedLangFile.length === 0) {
console.log(`Language file ${lang_id} doesn't exist!`)
return
}
console.log('\nMissing Keys:')
baseLangFile.forEach(key => {
if (!comparedLangFile.includes(key)) console.log(key)
})
console.log('\nExtra Keys:')
comparedLangFile.forEach(key => {
if (!baseLangFile.includes(key)) console.log(key)
})
}
;(async () => {
const args = process.argv.slice(2)
if (args.length !== 1) {
console.log('Usage:\nyarn testlang [COUNTRY_ID]\n')
return
}
console.log(`Testing language file ${args[0]}`)
await testLang(args[0])
console.log('')
})()

View File

@@ -0,0 +1,16 @@
import { checkNewRelease } from '../../../src/utils/dates.js'
describe('date utils', () => {
describe('checkNewRelease', () => {
it("returns a positive result checking today's date", () => {
expect(checkNewRelease(new Date())).toBe(true)
})
it("returns a negative result checking a week ago's date", () => {
const dateToCheck = new Date()
dateToCheck.setDate(dateToCheck.getDate() - 7)
expect(checkNewRelease(dateToCheck)).toBe(false)
})
})
})

View File

@@ -0,0 +1,12 @@
import { aggregateDownloadLinks } from '../../../src/utils/downloads'
describe('download utils', () => {
describe('aggregateDownloadLinks', () => {
it('merges links into a single string', () => {
const release = { link: 'abcde' }
const aggregated = aggregateDownloadLinks([release, release])
expect(aggregated).toBe('abcde;abcde')
})
})
})

View File

@@ -0,0 +1,17 @@
import { upperCaseFirstLowerCaseRest } from '../../../src/utils/texts'
describe('texts utils', () => {
describe('upperCaseFirstLowerCaseRest', () => {
it('converts a full uppercase string', () => {
expect(upperCaseFirstLowerCaseRest('TEST STRING')).toBe('Test string')
})
it('converts a full lowercase string', () => {
expect(upperCaseFirstLowerCaseRest('test string')).toBe('Test string')
})
it('converts a mixed string', () => {
expect(upperCaseFirstLowerCaseRest("i wOn'T woRK")).toBe("I won't work")
})
})
})

View File

@@ -0,0 +1,33 @@
import { isValidURL, convertDuration, convertDurationSeparated } from '../../../src/utils/utils'
describe('utils utils (needs refactor)', () => {
describe('isValidURL', () => {
it('returns a positive result with all supported URLs', () => {
expect(isValidURL('https://www.deezer.com')).toBe(true)
expect(isValidURL('https://deezer.page.link')).toBe(true)
expect(isValidURL('https://open.spotify.com')).toBe(true)
expect(isValidURL('https://link.tospotify.com')).toBe(true)
expect(isValidURL('spotify:something')).toBe(true)
})
it('returns a negative result with a not supported URL', () => {
expect(isValidURL('https://www.google.com')).toBe(false)
})
})
describe('convertDuration', () => {
it('converts seconds in the correct format', () => {
expect(convertDuration(120)).toBe('2:00')
expect(convertDuration(60)).toBe('1:00')
expect(convertDuration(30)).toBe('0:30')
})
})
describe('convertDurationSeparated', () => {
it('converts seconds in the correct format', () => {
expect(convertDurationSeparated(120)).toStrictEqual([0, 2, 0])
expect(convertDurationSeparated(60)).toStrictEqual([0, 1, 0])
expect(convertDurationSeparated(30)).toStrictEqual([0, 0, 30])
})
})
})