@@ -10,6 +10,7 @@ import {
1010 isInputElement ,
1111} from '@components/scripts/assertions/elements'
1212import DownloadFormComponent from '@components/Forms/Download/index.astro'
13+ import { TestError } from '@test/errors'
1314
1415// Mock the logger to suppress error output in tests
1516vi . mock ( '@lib/logger' , ( ) => ( {
@@ -42,32 +43,32 @@ async function setupDownloadFormDOM() {
4243function getDownloadFormElements ( ) {
4344 const form = document . getElementById ( 'downloadForm' )
4445 if ( ! isFormElement ( form ) ) {
45- throw new Error ( 'Download form element not found' )
46+ throw new TestError ( 'Download form element not found' )
4647 }
4748
4849 const firstName = form . querySelector ( '#firstName' )
4950 if ( ! isInputElement ( firstName ) ) {
50- throw new Error ( 'firstName input not found' )
51+ throw new TestError ( 'firstName input not found' )
5152 }
5253
5354 const lastName = form . querySelector ( '#lastName' )
5455 if ( ! isInputElement ( lastName ) ) {
55- throw new Error ( 'lastName input not found' )
56+ throw new TestError ( 'lastName input not found' )
5657 }
5758
5859 const workEmail = form . querySelector ( '#workEmail' )
5960 if ( ! isInputElement ( workEmail ) ) {
60- throw new Error ( 'workEmail input not found' )
61+ throw new TestError ( 'workEmail input not found' )
6162 }
6263
6364 const jobTitle = form . querySelector ( '#jobTitle' )
6465 if ( ! isInputElement ( jobTitle ) ) {
65- throw new Error ( 'jobTitle input not found' )
66+ throw new TestError ( 'jobTitle input not found' )
6667 }
6768
6869 const companyName = form . querySelector ( '#companyName' )
6970 if ( ! isInputElement ( companyName ) ) {
70- throw new Error ( 'companyName input not found' )
71+ throw new TestError ( 'companyName input not found' )
7172 }
7273
7374 return {
@@ -102,7 +103,7 @@ describe('DownloadForm class', () => {
102103 const formElement = document . getElementById ( 'downloadForm' )
103104
104105 if ( ! isFormElement ( formElement ) ) {
105- throw new Error ( 'Form element not found' )
106+ throw new TestError ( 'Form element not found' )
106107 }
107108
108109 const submitSpy = vi . fn ( ( e ) => e . preventDefault ( ) )
@@ -129,7 +130,7 @@ describe('DownloadForm class', () => {
129130 // Fill out the form
130131 const formElement = document . getElementById ( 'downloadForm' )
131132 if ( ! isFormElement ( formElement ) ) {
132- throw new Error ( 'Form element not found' )
133+ throw new TestError ( 'Form element not found' )
133134 }
134135
135136 const firstNameInput = formElement . querySelector ( '#firstName' )
@@ -141,7 +142,7 @@ describe('DownloadForm class', () => {
141142 if ( ! isInputElement ( firstNameInput ) || ! isInputElement ( lastNameInput ) ||
142143 ! isInputElement ( emailInput ) || ! isInputElement ( jobTitleInput ) ||
143144 ! isInputElement ( companyInput ) ) {
144- throw new Error ( 'Form inputs not found' )
145+ throw new TestError ( 'Form inputs not found' )
145146 }
146147
147148 firstNameInput . value = 'John'
@@ -261,7 +262,7 @@ describe('DownloadForm class', () => {
261262 const { form : formElement , firstName, lastName, workEmail, jobTitle, companyName } = getDownloadFormElements ( )
262263 const submitBtn = document . getElementById ( 'downloadSubmitBtn' )
263264 if ( ! submitBtn || ! ( submitBtn instanceof HTMLButtonElement ) ) {
264- throw new Error ( 'Submit button not found' )
265+ throw new TestError ( 'Submit button not found' )
265266 }
266267
267268 // Fill form
0 commit comments