Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to check if widget enum matches widgets names #837

Merged
merged 3 commits into from Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/tests/libs/widgets-loader.test.ts
@@ -0,0 +1,20 @@
import { expect, test } from 'vitest'

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

test('Test widgets exist', async () => {
const loader = await Promise.allSettled(
Object.values(WidgetType).map((name) => import(`@/components/widgets/${name}.vue`))
)
const found_all_files = loader.every((file) => {
JoaoMario109 marked this conversation as resolved.
Show resolved Hide resolved
if (file.status == 'fulfilled') {
return true
}
const failed_to_find = file.reason.message.includes('Failed to load')
if (failed_to_find) {
console.error(`Failed to find: ${file.reason}`)
}
return !failed_to_find
})
expect(found_all_files).toBe(true)
})
2 changes: 1 addition & 1 deletion src/types/widgets.ts
Expand Up @@ -11,7 +11,7 @@ export enum WidgetType {
DepthHUD = 'DepthHUD',
CompassHUD = 'CompassHUD',
IFrame = 'IFrame',
ImageViewer = 'ImageViewer',
ImageView = 'ImageView',
Map = 'Map',
MiniWidgetsBar = 'MiniWidgetsBar',
URLVideoPlayer = 'URLVideoPlayer',
Expand Down
8 changes: 0 additions & 8 deletions vite.config.ts
Expand Up @@ -34,13 +34,5 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
coverage: {
branches: 90,
functions: 95,
lines: 98,
perFile: true,
reporter: ['html', 'text'],
statements: 95,
},
},
})