diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index db4974631..841bf8bab 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16] + node-version: [16, 18, 20] steps: - uses: actions/checkout@v3 diff --git a/packages/happy-dom/src/nodes/html-input-element/HTMLInputElementDateUtility.ts b/packages/happy-dom/src/nodes/html-input-element/HTMLInputElementDateUtility.ts index f89e14658..0187c1a4a 100644 --- a/packages/happy-dom/src/nodes/html-input-element/HTMLInputElementDateUtility.ts +++ b/packages/happy-dom/src/nodes/html-input-element/HTMLInputElementDateUtility.ts @@ -14,8 +14,8 @@ export default class HTMLInputElementDateUtility { date.setUTCDate(date.getUTCDate() - day + 3); const firstThursday = date.getTime(); date.setUTCMonth(0, 1); - if (date.getDay() !== 4) { - date.setUTCMonth(0, 1 + ((4 - date.getDay() + 7) % 7)); + if (date.getUTCDay() !== 4) { + date.setUTCMonth(0, 1 + ((4 - date.getUTCDay() + 7) % 7)); } return ( date.getUTCFullYear() + @@ -37,7 +37,7 @@ export default class HTMLInputElementDateUtility { } const date = new Date(`${Y}-01-01T00:00Z`); const jan4th = new Date(`${Y}-01-04T00:00Z`); - const jan4thDay = (jan4th.getDay() + 6) % 7; + const jan4thDay = (jan4th.getUTCDay() + 6) % 7; const ordinalDate = 1 + (Number(W) - 1) * 7 - jan4thDay + 3; date.setUTCDate(ordinalDate); if (date.getUTCFullYear() > Number(Y)) { diff --git a/packages/happy-dom/test/nodes/html-input-element/HTMLInputElement.test.ts b/packages/happy-dom/test/nodes/html-input-element/HTMLInputElement.test.ts index abceaa4c8..1c181aa39 100644 --- a/packages/happy-dom/test/nodes/html-input-element/HTMLInputElement.test.ts +++ b/packages/happy-dom/test/nodes/html-input-element/HTMLInputElement.test.ts @@ -390,6 +390,7 @@ describe('HTMLInputElement', () => { { type: 'time', value: '00:00', want: new Date('1970-01-01T00:00Z') }, { type: 'time', value: '12:00', want: new Date('1970-01-01T12:00Z') }, { type: 'time', value: '18:55', want: new Date('1970-01-01T18:55Z') }, + { type: 'week', value: '1981-W01', want: new Date('1980-12-29T00:00Z') }, { type: 'week', value: '2023-W22', want: new Date('2023-05-29T00:00Z') } ])(`Should return valid date for type $type with valid value`, ({ type, value, want }) => { element.type = type; diff --git a/packages/happy-dom/test/window/Window.test.ts b/packages/happy-dom/test/window/Window.test.ts index 39a4363af..41d2761e3 100644 --- a/packages/happy-dom/test/window/Window.test.ts +++ b/packages/happy-dom/test/window/Window.test.ts @@ -874,7 +874,7 @@ describe('Window', () => { expect(((errorEvent)).error?.message).toBe('Test error'); expect(((errorEvent)).message).toBe('Test error'); resolve(null); - }, 15); + }, 20); }); }); }); @@ -1030,7 +1030,7 @@ describe('Window', () => { expect(((errorEvent)).error?.message).toBe('Test error'); expect(((errorEvent)).message).toBe('Test error'); resolve(null); - }, 10); + }, 20); }); }); }); diff --git a/packages/uncaught-exception-observer/test/UncaughtExceptionObserver.test.ts b/packages/uncaught-exception-observer/test/UncaughtExceptionObserver.test.ts index a3b42305f..7d5f9df22 100644 --- a/packages/uncaught-exception-observer/test/UncaughtExceptionObserver.test.ts +++ b/packages/uncaught-exception-observer/test/UncaughtExceptionObserver.test.ts @@ -70,15 +70,17 @@ async function itObservesUnhandledJavaScriptFetchRejections(): Promise { } if ( - errorEvent.error.message !== - 'Fetch to "https://localhost:3000/404.js" failed. Error: connect ECONNREFUSED 127.0.0.1:3000' + !errorEvent.error.message.startsWith( + 'Fetch to "https://localhost:3000/404.js" failed. Error: connect ECONNREFUSED' + ) ) { throw new Error('Error message not correct.'); } if ( - errorEvent.message !== - 'Fetch to "https://localhost:3000/404.js" failed. Error: connect ECONNREFUSED 127.0.0.1:3000' + !errorEvent.message.startsWith( + 'Fetch to "https://localhost:3000/404.js" failed. Error: connect ECONNREFUSED' + ) ) { throw new Error('Error message not correct.'); }