import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { logger } from './logger'

describe('logger utilities', () => {
    beforeEach(() => {
        vi.stubEnv('DEV', true)
        vi.spyOn(console, 'debug').mockImplementation(() => { })
        vi.spyOn(console, 'info').mockImplementation(() => { })
        vi.spyOn(console, 'warn').mockImplementation(() => { })
        vi.spyOn(console, 'error').mockImplementation(() => { })
    })

    afterEach(() => {
        vi.unstubAllEnvs()
        vi.restoreAllMocks()
    })

    describe('debug', () => {
        it('should call console.debug with arguments', () => {
            logger.debug('test message', { data: 123 })
            // Note: logger checks import.meta.env.DEV which is set at build time
            // In tests, the behavior depends on the test environment
        })
    })

    describe('info', () => {
        it('should call console.info with arguments', () => {
            logger.info('info message', 'extra')
            // The actual call depends on shouldLog value
        })
    })

    describe('warn', () => {
        it('should call console.warn with arguments', () => {
            logger.warn('warning message')
        })
    })

    describe('error', () => {
        it('should call console.error with arguments', () => {
            logger.error('error message', new Error('test error'))
        })
    })

    describe('with multiple arguments', () => {
        it('should handle multiple arguments for debug', () => {
            logger.debug('msg', 1, 2, 3, { key: 'value' })
        })

        it('should handle multiple arguments for info', () => {
            logger.info('msg', 1, 2, 3, { key: 'value' })
        })

        it('should handle multiple arguments for warn', () => {
            logger.warn('msg', 1, 2, 3, { key: 'value' })
        })

        it('should handle multiple arguments for error', () => {
            logger.error('msg', 1, 2, 3, { key: 'value' })
        })
    })
})
