summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/tests/lib/components/ChangePassword.svelte.test.js35
-rw-r--r--ui/tests/lib/components/CreateChannelForm.svelte.test.js8
-rw-r--r--ui/tests/lib/components/Invite.svelte.test.js8
-rw-r--r--ui/tests/lib/components/LogOut.svelte.test.js8
-rw-r--r--ui/tests/lib/components/Message.svelte.test.js9
-rw-r--r--ui/tests/lib/components/MessageInput.svelte.test.js9
6 files changed, 77 insertions, 0 deletions
diff --git a/ui/tests/lib/components/ChangePassword.svelte.test.js b/ui/tests/lib/components/ChangePassword.svelte.test.js
new file mode 100644
index 0000000..09aa992
--- /dev/null
+++ b/ui/tests/lib/components/ChangePassword.svelte.test.js
@@ -0,0 +1,35 @@
+import { flushSync, mount, unmount } from 'svelte';
+import { afterEach, describe, beforeEach, expect, test, vi } from 'vitest';
+import ChangePassword from '$lib/components/ChangePassword.svelte';
+import axios from 'axios';
+
+vi.mock('axios');
+
+describe('ChangePassword', () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ test('onsubmit happy path', async () => {
+ axios.post.mockResolvedValue({ status: 200 });
+
+ // Instantiate the component using Svelte's `mount` API
+ const component = mount(ChangePassword, {
+ target: document.body, // `document` exists because of jsdom
+ });
+ flushSync();
+
+ // Set value in all three inputs at once:
+ const inputs = document.body.querySelectorAll('input[type=password]');
+ inputs.value = 'pass';
+ // Click the button, then flush the changes so you can synchronously write expectations
+ document.body.querySelector('button[type=submit]').click();
+ flushSync();
+
+ // expect(axios.post).toHaveBeenCalledWith('/password', { password: 'pass', to: 'pass' });
+ expect(Array.from(inputs.values()).map((i) => i.value)).toEqual(['', '', '']);
+
+ // Remove the component from the DOM
+ unmount(component);
+ });
+});
diff --git a/ui/tests/lib/components/CreateChannelForm.svelte.test.js b/ui/tests/lib/components/CreateChannelForm.svelte.test.js
new file mode 100644
index 0000000..31f7462
--- /dev/null
+++ b/ui/tests/lib/components/CreateChannelForm.svelte.test.js
@@ -0,0 +1,8 @@
+// async handleSubmit(event)
+import { describe, expect, test } from 'vitest';
+
+describe('CreateChannelForm', () => {
+ test('stub', async () => {
+ expect(true).toBeTruthy();
+ });
+});
diff --git a/ui/tests/lib/components/Invite.svelte.test.js b/ui/tests/lib/components/Invite.svelte.test.js
new file mode 100644
index 0000000..5d5742e
--- /dev/null
+++ b/ui/tests/lib/components/Invite.svelte.test.js
@@ -0,0 +1,8 @@
+// async onsubmit(event)
+import { describe, expect, test } from 'vitest';
+
+describe('Invite', () => {
+ test('stub', async () => {
+ expect(true).toBeTruthy();
+ });
+});
diff --git a/ui/tests/lib/components/LogOut.svelte.test.js b/ui/tests/lib/components/LogOut.svelte.test.js
new file mode 100644
index 0000000..65d78a9
--- /dev/null
+++ b/ui/tests/lib/components/LogOut.svelte.test.js
@@ -0,0 +1,8 @@
+// async onsubmit(event)
+import { describe, expect, test } from 'vitest';
+
+describe('LogOut', () => {
+ test('stub', async () => {
+ expect(true).toBeTruthy();
+ });
+});
diff --git a/ui/tests/lib/components/Message.svelte.test.js b/ui/tests/lib/components/Message.svelte.test.js
new file mode 100644
index 0000000..2ca0b85
--- /dev/null
+++ b/ui/tests/lib/components/Message.svelte.test.js
@@ -0,0 +1,9 @@
+// onDelete(event)
+// onmouseleave()
+import { describe, expect, test } from 'vitest';
+
+describe('Message', () => {
+ test('stub', async () => {
+ expect(true).toBeTruthy();
+ });
+});
diff --git a/ui/tests/lib/components/MessageInput.svelte.test.js b/ui/tests/lib/components/MessageInput.svelte.test.js
new file mode 100644
index 0000000..597f0c3
--- /dev/null
+++ b/ui/tests/lib/components/MessageInput.svelte.test.js
@@ -0,0 +1,9 @@
+// async onSubmit(event)
+// onKeyDown(event)
+import { describe, expect, test } from 'vitest';
+
+describe('MessageInput', () => {
+ test('stub', async () => {
+ expect(true).toBeTruthy();
+ });
+});