Skip to content

Commit 9370bf8

Browse files
committed
fix: unit test
1 parent d672c23 commit 9370bf8

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

test/unit/breakpoints.test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@ describe('Breakpoints - Smoke Tests', () => {
1414
});
1515

1616
it('should apply breakpoints when enabled with playerElement', () => {
17-
const parent = document.createElement('div');
17+
const player = document.createElement('video');
18+
player.className = 'cld-video-player';
1819
// Mock clientWidth since element isn't rendered in test
19-
Object.defineProperty(parent, 'clientWidth', {
20+
Object.defineProperty(player, 'clientWidth', {
2021
configurable: true,
2122
value: 500
2223
});
2324

24-
const player = document.createElement('video');
25-
Object.defineProperty(player, 'parentElement', {
26-
configurable: true,
27-
value: parent
28-
});
25+
// Add player to DOM so document.querySelector can find it
26+
document.body.appendChild(player);
2927

3028
const source = new VideoSource('sea_turtle', {
3129
cloudinaryConfig: cld,
3230
breakpoints: true,
3331
dpr: 1.5
3432
});
3533

36-
const srcs = source.generateSources(player);
34+
const srcs = source.generateSources();
35+
36+
// Clean up
37+
document.body.removeChild(player);
38+
3739
// Should contain width (500), DPR (1.5), and crop limit
3840
expect(srcs[0].src).toContain('w_500');
3941
expect(srcs[0].src).toContain('dpr_1.5');

0 commit comments

Comments
 (0)