-
Notifications
You must be signed in to change notification settings - Fork 2
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
36f1e2d
commit 43f1676
Showing
8 changed files
with
480 additions
and
265 deletions.
There are no files selected for viewing
479 changes: 259 additions & 220 deletions
479
src/src/lib/components/annotations/3dAnnotations.svelte
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { render, fireEvent } from '@testing-library/svelte'; | ||
import ModalComponent from '$lib/components/modals/quizzes/Add.svelte'; | ||
|
||
describe('ModalComponent - Add Quiz Modal', () => { | ||
const defaultProps = { | ||
open: true | ||
}; | ||
|
||
it('should open modal when open is true', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
expect(getByText('Add Quiz')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide modal when open is false', () => { | ||
const { queryByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: false } | ||
}); | ||
|
||
expect(queryByText('Add Quiz')).not.toBeInTheDocument(); | ||
}); | ||
|
||
|
||
|
||
it('should submit form with valid inputs', async () => { | ||
const { getByLabelText, getByRole, getByText } = render(ModalComponent, { | ||
props: { ...defaultProps } | ||
}); | ||
|
||
const titleInput = getByLabelText('Title') as HTMLInputElement; | ||
const durationInput = getByLabelText('Duration (in minutes)') as HTMLInputElement; | ||
const instructionsTextarea = getByLabelText('Add Instructions') as HTMLTextAreaElement; | ||
const submitButton = getByRole('button', { name: 'Create Quiz' }); | ||
|
||
|
||
await fireEvent.input(titleInput, { target: { value: 'New Quiz' } }); | ||
await fireEvent.input(durationInput, { target: { value: '45' } }); | ||
await fireEvent.input(instructionsTextarea, { target: { value: 'These are instructions.' } }); | ||
|
||
// Simulate form submission | ||
await fireEvent.click(submitButton); | ||
|
||
expect(titleInput.value).toBe('New Quiz'); | ||
expect(durationInput.value).toBe('45'); | ||
expect(instructionsTextarea.value).toBe('These are instructions.'); | ||
}); | ||
|
||
it('should display toolbar buttons correctly', () => { | ||
const { getByRole } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
expect(getByRole('button', { name: 'Attach file' })).toBeInTheDocument(); | ||
expect(getByRole('button', { name: 'Embed map' })).toBeInTheDocument(); | ||
expect(getByRole('button', { name: 'Upload image' })).toBeInTheDocument(); | ||
expect(getByRole('button', { name: 'Format code' })).toBeInTheDocument(); | ||
expect(getByRole('button', { name: 'Add emoji' })).toBeInTheDocument(); | ||
}); | ||
}); |
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,67 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { render, fireEvent } from '@testing-library/svelte'; | ||
import ModalComponent from '$lib/components/modals/quizzes/Edit.svelte'; | ||
|
||
describe('ModalComponent - Question Type Modal', () => { | ||
const defaultProps = { | ||
open: true | ||
}; | ||
|
||
it('should open modal when open is true', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
expect(getByText('Choose Question Type')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display "Add" button and disable it when no option is selected', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
const addButton = getByText('Add'); | ||
expect(addButton).toBeInTheDocument(); | ||
expect(addButton).toBeDisabled(); | ||
}); | ||
|
||
it('should enable "Add" button when a question type is selected', async () => { | ||
const { getByText, getByLabelText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
const selectInput = getByLabelText('Select Question Type'); | ||
const addButton = getByText('Add'); | ||
|
||
// Initially disabled | ||
expect(addButton).toBeDisabled(); | ||
|
||
// Simulate selecting a question type | ||
await fireEvent.change(selectInput, { target: { value: 'multiple-choice' } }); | ||
|
||
// Now the button should be enabled | ||
expect(addButton).not.toBeDisabled(); | ||
}); | ||
|
||
it('should close modal when "Add" button is clicked with a valid selection', async () => { | ||
const { getByText, getByLabelText, component } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
const selectInput = getByLabelText('Select Question Type'); | ||
const addButton = getByText('Add'); | ||
|
||
// Mock the dispatch event listener | ||
let dispatchedEvent = null; | ||
component.$on('select', (event) => { | ||
dispatchedEvent = event.detail; | ||
}); | ||
|
||
// Simulate selecting a question type and clicking the "Add" button | ||
await fireEvent.change(selectInput, { target: { value: '3d-hotspot' } }); | ||
await fireEvent.click(addButton); | ||
|
||
// Check if the event was dispatched correctly with the selected type | ||
expect(dispatchedEvent).toEqual({ type: '3d-hotspot' }); | ||
}); | ||
}); |
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,45 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { render, fireEvent } from '@testing-library/svelte'; | ||
import ModalComponent from '$lib/components/modals/quizzes/Submission.svelte'; // Adjust the import path as needed | ||
|
||
// Mock the navigation function | ||
vi.mock('$utils/navigation', () => ({ | ||
navigateToParentRoute: vi.fn() | ||
})); | ||
|
||
describe('ModalComponent - Quiz Submission Modal', () => { | ||
const defaultProps = { | ||
open: true, | ||
submissionMessage: 'Your quiz has been submitted successfully!', | ||
percentageScore: 85.5 | ||
}; | ||
|
||
it('should open modal when open is true', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
expect(getByText('Quiz Submission')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide modal when open is false', () => { | ||
const { queryByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: false } | ||
}); | ||
|
||
expect(queryByText('Quiz Submission')).not.toBeInTheDocument(); | ||
}); | ||
|
||
|
||
|
||
it('should display submission message and percentage score correctly', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: defaultProps | ||
}); | ||
|
||
expect(getByText('Your quiz has been submitted successfully!')).toBeInTheDocument(); | ||
expect(getByText('Percentage Score: 85.50%')).toBeInTheDocument(); | ||
}); | ||
|
||
|
||
}); |
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,45 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { render, fireEvent } from '@testing-library/svelte'; | ||
import ModalComponent from '$lib/components/modals/quizzes/TimeElapsed.svelte'; // Adjust the import path as needed | ||
|
||
// Mock the navigation function | ||
vi.mock('$utils/navigation', () => ({ | ||
navigateToParentRoute: vi.fn() | ||
})); | ||
|
||
describe('ModalComponent - Time Elapsed Modal', () => { | ||
const defaultProps = { | ||
open: true, | ||
submissionMessage: 'Time is up! You have completed the quiz.', | ||
totalPoints: 85 | ||
}; | ||
|
||
it('should open modal when open is true', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: true } | ||
}); | ||
|
||
expect(getByText('Time Elapsed')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide modal when open is false', () => { | ||
const { queryByText } = render(ModalComponent, { | ||
props: { ...defaultProps, open: false } | ||
}); | ||
|
||
expect(queryByText('Time Elapsed')).not.toBeInTheDocument(); | ||
}); | ||
|
||
|
||
|
||
it('should display submission message and total points correctly', () => { | ||
const { getByText } = render(ModalComponent, { | ||
props: defaultProps | ||
}); | ||
|
||
expect(getByText('Time is up! You have completed the quiz.')).toBeInTheDocument(); | ||
expect(getByText('Total Points: 85')).toBeInTheDocument(); | ||
}); | ||
|
||
|
||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.