-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d22780
commit 879cfaf
Showing
7 changed files
with
118 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/resources/js/Pages/Invitation/Partials/InvitationForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script setup lang="ts"> | ||
import PrimaryButton from '@/Components/PrimaryButton.vue'; | ||
import InputError from '@/Components/InputError.vue'; | ||
import InputLabel from '@/Components/InputLabel.vue'; | ||
import TextInput from '@/Components/TextInput.vue'; | ||
import { useForm } from '@inertiajs/vue3'; | ||
const form = useForm({ | ||
email: '', | ||
}); | ||
const submit = () => { | ||
form.post(route('invitation.send'), { | ||
onSuccess: () => { | ||
form.reset(); | ||
}, | ||
}); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<form class="p-6 text-gray-900 dark:text-gray-100" @submit.prevent="submit"> | ||
<div> | ||
<InputLabel for="email" value="Email" /> | ||
|
||
<TextInput | ||
id="email" | ||
v-model="form.email" | ||
type="email" | ||
class="mt-1 block w-full" | ||
required | ||
autofocus | ||
autocomplete="email" | ||
/> | ||
|
||
<InputError class="mt-2" :message="form.errors.email" /> | ||
</div> | ||
|
||
<div class="flex justify-end mt-4"> | ||
<PrimaryButton | ||
class="ml-4" | ||
:class="{ 'opacity-25': form.processing }" | ||
:disabled="form.processing" | ||
> | ||
Send invitation | ||
</PrimaryButton> | ||
</div> | ||
</form> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import { describe, expect, it } from 'vitest'; | ||
import Footer from '@/Components/Footer.vue'; | ||
|
||
describe('Footer test (Footer.vue)', () => { | ||
it('Renders correctly', () => { | ||
const wrapper = mount(Footer, { | ||
global: { | ||
mocks: { | ||
route: vitest.fn().mockReturnValue('dashboard'), | ||
}, | ||
}, | ||
}); | ||
|
||
expect(wrapper.exists()).toBeTruthy(); | ||
expect(wrapper.find('footer').exists()).toBeTruthy(); | ||
|
||
const dashboardLink = wrapper.findComponent({ name: 'Link' }); | ||
expect(dashboardLink.exists()).toBeTruthy(); | ||
expect(dashboardLink.text()).toContain('Anilibrary'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/resources/js/tests/Pages/Invitation/Partials/InvitationForm.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import InvitationForm from '@/Pages/Invitation/Partials/InvitationForm.vue'; | ||
import { describe, expect, it, vitest } from 'vitest'; | ||
|
||
describe('InvitationForm test (InvitationForm.vue)', () => { | ||
it('Renders correctly', () => { | ||
const wrapper = mount(InvitationForm); | ||
|
||
expect(wrapper.find('form').exists()).toBeTruthy(); | ||
expect(wrapper.find('label').exists()).toBeTruthy(); | ||
expect(wrapper.find('input').exists()).toBeTruthy(); | ||
expect(wrapper.find('button').exists()).toBeTruthy(); | ||
}); | ||
|
||
it('Creates invitation', async () => { | ||
global.route = vitest.fn(); | ||
const wrapper = mount(InvitationForm); | ||
|
||
wrapper.vm.form.post = vitest.fn(); | ||
wrapper.vm.form.reset = vitest.fn(); | ||
wrapper.vm.form.email = 'test@example.com'; | ||
await wrapper.find('form').trigger('submit.prevent'); | ||
|
||
expect(wrapper.vm.form.post).toHaveBeenCalled(); | ||
}); | ||
|
||
it('Disables button during form processing', async () => { | ||
const wrapper = mount(InvitationForm); | ||
|
||
wrapper.vm.form.processing = true; | ||
await wrapper.vm.$nextTick(); | ||
|
||
expect(wrapper.find('button').element.disabled).toBeTruthy(); | ||
}); | ||
}); |