Add testing frameworks

This commit is contained in:
Djuri 2023-11-23 02:04:20 +01:00
parent fd492c416c
commit a9c12c2e9f
11 changed files with 1315 additions and 189 deletions

30
src/routes/Status.spec.ts Normal file
View file

@ -0,0 +1,30 @@
import { writable } from 'svelte/store';
import Status from './Status.svelte';
import { render } from '@testing-library/svelte';
import { describe, test, expect, beforeEach } from 'vitest';
import { locale, init, addMessages } from 'svelte-i18n';
import '$lib/i18n/index.ts';
import en from '$lib/locales/en.json';
addMessages('en', en);
describe('Status Component', () => {
beforeEach(() => {
init({
fallbackLocale: 'en',
initialLocale: 'en'
});
locale.set('en');
});
test('should render the component', () => {
const host = document.createElement('div');
document.body.appendChild(host);
const instance = render(Status, {
target: host,
props: { status: writable([]), settings: writable([]) }
});
expect(instance).toBeTruthy();
expect(host.innerHTML).toContain('Status');
});
});