Skip to content

Commit

Permalink
Merge pull request #1391 from capricorn86/1390-add-bun-integration-te…
Browse files Browse the repository at this point in the history
…st-for-adding-an-event-listener

chore: [#1390] Adds Bun integration test for adding an event listener
  • Loading branch information
capricorn86 committed Apr 7, 2024
2 parents 4849b62 + b873d7b commit ff09e4f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions packages/global-registrator/test/bun/Bun.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@ test('CSS', () => {
}
`;

expect(globalThis.getComputedStyle(document.body).backgroundColor).toBe('green');
expect(getComputedStyle(document.body).backgroundColor).toBe('green');
});

test('Add event listener', () => {
const div = document.createElement('div');
document.body.appendChild(div);

document.body.addEventListener('click', () => {
div.style.backgroundColor = 'green';
});

div.dispatchEvent(new Event('click', { bubbles: true }));

expect(getComputedStyle(div).backgroundColor).toBe('green');
});

test('Window getters', () => {
Expand All @@ -64,8 +77,8 @@ test('Window getters', () => {
});

test('Window location', () => {
globalThis.location.href = 'https://example.com/';
expect(globalThis.location.href).toBe('https://example.com/');
location.href = 'https://example.com/';
expect(location.href).toBe('https://example.com/');
});

test('Window options', () => {
Expand All @@ -82,8 +95,8 @@ test('Window options', () => {
}
});

expect(globalThis.location.href).toBe('https://example.com/');
expect(globalThis.innerWidth).toBe(1920);
expect(globalThis.innerHeight).toBe(1080);
expect(globalThis.navigator.userAgent).toBe('Custom User Agent');
expect(location.href).toBe('https://example.com/');
expect(innerWidth).toBe(1920);
expect(innerHeight).toBe(1080);
expect(navigator.userAgent).toBe('Custom User Agent');
});

0 comments on commit ff09e4f

Please sign in to comment.