Skip to content

Commit

Permalink
tests: widgets-loader: Update to add mini-widgets test
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Mar 27, 2024
1 parent f62d16c commit 228b3e7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/tests/libs/widgets-loader.test.ts
@@ -1,10 +1,20 @@
import { expect, test } from 'vitest'

import { WidgetType } from '@/types/widgets'
import { MiniWidgetType } from '@/types/miniWidgets'

test('Test widgets exist', async () => {
await enum_to_files_checker(WidgetType, '@/components/widgets/${name}.vue')
})


test('Test mini-widgets exist', async () => {
await enum_to_files_checker(MiniWidgetType, '@/components/mini-widgets/${name}.vue')
})

async function enum_to_files_checker<T>(enum_type: T, path_template: string): Promise<void> {
const loader = await Promise.allSettled(
Object.values(WidgetType).map((name) => import(`@/components/widgets/${name}.vue`))
Object.values(enum_type).map((name) => import(eval('`' + path_template + '`'))) // Please, have marcy of my soul
)
const found_all_files = loader.every((file) => {
if (file.status == 'fulfilled') {
Expand All @@ -17,4 +27,4 @@ test('Test widgets exist', async () => {
return !failed_to_find
})
expect(found_all_files).toBe(true)
})
}

0 comments on commit 228b3e7

Please sign in to comment.