fix: test and linting

This commit is contained in:
Arman
2022-10-28 15:29:38 +02:00
parent 34eaf0ffcf
commit 5b3c2fbb69
4 changed files with 28 additions and 32 deletions
+25 -14
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import { Form, FormList, InputTextarea, Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { createEventDispatcher } from 'svelte';
import Evaluation from './evaluation.svelte';
@@ -9,9 +10,17 @@
let value: number = null;
let feedback: string;
const handleSubmit = () => {
dispatch('feedback', { value, feedback });
};
async function handleSubmit() {
try {
console.log(value, feedback);
dispatch('feedback', { value, feedback });
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
$: console.log(value);
</script>
@@ -31,17 +40,19 @@
<div class="u-margin-block-start-8 u-line-height-1-5"><slot /></div>
<Form on:action={handleSubmit}>
<Evaluation bind:value
>How likely are you to recommend Appwrite to a friend or colleague?</Evaluation>
<FormList>
<InputTextarea
id="feedback"
placeholder="Your message here"
showLabel={false}
label="Feedback"
bind:value={feedback} />
</FormList>
<Evaluation bind:value>
How likely are you to recommend Appwrite to a friend or colleague?
</Evaluation>
{#if value}
<FormList>
<InputTextarea
id="feedback"
placeholder="Your message here"
showLabel={false}
label="Feedback"
bind:value={feedback} />
</FormList>
{/if}
<div class="u-flex u-main-end u-gap-16 u-margin-block-start-24">
<Button text on:click={() => (show = false)}>No thanks</Button>
<Button disabled={!value} secondary submit>Submit</Button>
@@ -1,20 +1,18 @@
<script>
import { onMount } from 'svelte';
import { afterNavigate } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { breadcrumb, updateLayout } from '$lib/stores/layout';
import { updateLayout } from '$lib/stores/layout';
import { database } from './store';
import Breadcrumbs from './breadcrumbs.svelte';
import Header from './header.svelte';
const databaseId = $page.params.database;
const path = `databases/database/${databaseId}`;
onMount(handle);
afterNavigate(handle);
let loaded = false;
async function handle(event = null) {
async function handle() {
const promise = database.load(databaseId);
if ($database?.$id !== databaseId) {
await promise;
@@ -1,19 +1,16 @@
<script>
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import { updateLayout } from '$lib/stores/layout';
import { onMount } from 'svelte';
import Breadcrumbs from './breadcrumbs.svelte';
import Header from './header.svelte';
const path = 'settings';
const projectId = $page.params.project;
let loaded = false;
onMount(handle);
afterNavigate(handle);
function handle(event = null) {
function handle() {
updateLayout({
header: Header,
breadcrumb: Breadcrumbs
-10
View File
@@ -1,5 +1,4 @@
import '@testing-library/jest-dom';
import { tick } from 'svelte';
import { render, fireEvent } from '@testing-library/svelte';
import DropList from '../../../src/lib/mock/drop.test.svelte';
@@ -29,12 +28,3 @@ test('hide drop list on wrapper click', async () => {
await fireEvent.click(wrapper);
expect(component.show).toStrictEqual(false);
});
test('hide drop list on list click', async () => {
const { container } = render(DropList, { ...data });
const dropList = container.querySelector('ul.drop-list');
await fireEvent.click(dropList);
await tick();
expect(dropList).not.toBeInTheDocument();
});