fix: test

This commit is contained in:
Xavier Araque 2025-11-07 16:01:28 +01:00
parent a82a03feda
commit f54229ea50
2 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@ describe('usePreloading', () => {
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks() vi.clearAllMocks()
// Mock Audio constructor // Mock Audio constructor
global.Audio = vi.fn().mockImplementation(function() { global.Audio = vi.fn().mockImplementation(function () {
this.src = '' this.src = ''
this.addEventListener = vi.fn() this.addEventListener = vi.fn()
}) })
@ -119,7 +119,7 @@ describe('usePreloading', () => {
it('should handle audio load errors gracefully', () => { it('should handle audio load errors gracefully', () => {
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
global.Audio = vi.fn().mockImplementation(function() { global.Audio = vi.fn().mockImplementation(function () {
this.src = '' this.src = ''
this.addEventListener = vi.fn((event, callback) => { this.addEventListener = vi.fn((event, callback) => {
if (event === 'error') { if (event === 'error') {

View File

@ -16,7 +16,7 @@ describe('useReplayGain', () => {
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks() vi.clearAllMocks()
// Mock Web Audio API // Mock Web Audio API
global.AudioContext = vi.fn().mockImplementation(function() { global.AudioContext = vi.fn().mockImplementation(function () {
this.createMediaElementSource = vi.fn(() => ({ this.createMediaElementSource = vi.fn(() => ({
connect: vi.fn(), connect: vi.fn(),
})) }))
@ -85,7 +85,7 @@ describe('useReplayGain', () => {
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
// Mock AudioContext to throw error // Mock AudioContext to throw error
global.AudioContext = vi.fn().mockImplementation(function() { global.AudioContext = vi.fn().mockImplementation(function () {
throw new Error('Web Audio API not supported') throw new Error('Web Audio API not supported')
}) })
@ -125,7 +125,7 @@ describe('useReplayGain', () => {
connect: vi.fn(), connect: vi.fn(),
} }
global.AudioContext = vi.fn().mockImplementation(function() { global.AudioContext = vi.fn().mockImplementation(function () {
this.createMediaElementSource = vi.fn(() => ({ this.createMediaElementSource = vi.fn(() => ({
connect: vi.fn(), connect: vi.fn(),
})) }))