import { describe, expect, test } from 'vitest'
import { macOS } from '../src'

describe('macOS', () => {
  test('appleOtpauth should return a URL', async () => {
    const url = macOS.appleOtpauth()
    expect(url).toBe('apple-otpauth://')
  })

  test('fontbook should return a URL', async () => {
    const url = macOS.fontbook()
    expect(url).toBe('fontbook://')
  })

  test('keynote should return a URL', async () => {
    const url = macOS.keynote()
    expect(url).toBe('com.apple.iwork.keynote-share://')
  })

  test('numbers should return a URL', async () => {
    const url = macOS.numbers()
    expect(url).toBe('com.apple.iwork.numbers-share://')
  })

  test('pages should return a URL', async () => {
    const url = macOS.pages()
    expect(url).toBe('com.apple.iwork.pages-share://')
  })

  test('sms should return a URL without phone', async () => {
    const url = macOS.sms()
    expect(url).toBe('sms://')
  })

  test('sms should return a URL with phone', async () => {
    const url = macOS.sms({ phone: '1234567890' })
    expect(url).toBe('sms://1234567890')
  })

  test('facetime should return a URL with phone', async () => {
    const url = macOS.facetime({ phone: '1234567890' })
    expect(url).toBe('tel://1234567890')
  })

  test('mail should return a URL', async () => {
    const url = macOS.mail()
    expect(url).toBe('message://')
  })

  test('wallet should return a URL', async () => {
    const url = macOS.wallet()
    expect(url).toBe('shoebox://')
  })

  test('calendar should return a URL without link', async () => {
    const url = macOS.calendar()
    expect(url).toBe('ical://')
  })

  test('calendar should return a URL with webcal link', async () => {
    const url = macOS.calendar({ link: 'https://example.com/calendar.ics' })
    expect(url).toBe('webcal://example.com/calendar.ics')
  })

  test('calendar should convert http to webcal', async () => {
    const url = macOS.calendar({ link: 'http://example.com/calendar.ics' })
    expect(url).toBe('webcal://example.com/calendar.ics')
  })

  test('findMy should return a URL without tab', async () => {
    const url = macOS.findMy()
    expect(url).toBe('findmy://')
  })

  test('findMy should return a URL with devices tab', async () => {
    const url = macOS.findMy({ tab: 'devices' })
    expect(url).toBe('findmy://devices')
  })

  test('findMy should return a URL with items tab', async () => {
    const url = macOS.findMy({ tab: 'items' })
    expect(url).toBe('findmy://items')
  })

  test('findMy should return a URL with friends tab', async () => {
    const url = macOS.findMy({ tab: 'friends' })
    expect(url).toBe('findmy://friends')
  })

  test('stocks should return a URL without symbol', async () => {
    const url = macOS.stocks()
    expect(url).toBe('stocks://')
  })

  test('stocks should return a URL with symbol', async () => {
    const url = macOS.stocks({ symbol: 'GE' })
    expect(url).toBe('stocks://?symbol=GE')
  })

  test('videos should return a URL', async () => {
    const url = macOS.videos()
    expect(url).toBe('videos://')
  })

  test('weather should return a URL', async () => {
    const url = macOS.weather()
    expect(url).toBe('weather://')
  })

  test('addressbook should return a URL', async () => {
    const url = macOS.addressbook()
    expect(url).toBe('addressbook://')
  })

  test('notes should return a URL', async () => {
    const url = macOS.notes()
    expect(url).toBe('notes://')
  })

  test('reminders should return a URL', async () => {
    const url = macOS.reminders()
    expect(url).toBe('x-apple-reminderkit://')
  })

  test('feedback should return a URL without type', async () => {
    const url = macOS.feedback()
    expect(url).toBe('applefeedback://')
  })

  test('feedback should return a URL with new type', async () => {
    const url = macOS.feedback({ type: 'new' })
    expect(url).toBe('applefeedback://new')
  })

  test('photos should return a URL', async () => {
    const url = macOS.photos()
    expect(url).toBe('photos://')
  })

  test('music should return a URL', async () => {
    const url = macOS.music()
    expect(url).toBe('music://')
  })

  test('podcasts should return a URL', async () => {
    const url = macOS.podcasts()
    expect(url).toBe('pcast://')
  })

  test('books should return a URL', async () => {
    const url = macOS.books()
    expect(url).toBe('ibooks://')
  })

  test('systemPreferences should return a URL without pane', async () => {
    const url = macOS.systemPreferences()
    expect(url).toBe('x-apple.systempreferences:')
  })

  test('systemPreferences should return a URL with security pane', async () => {
    const url = macOS.systemPreferences({ pane: 'com.apple.preference.security' })
    expect(url).toBe('x-apple.systempreferences:com.apple.preference.security')
  })

  test('systemPreferences should return a URL with softwareupdate pane', async () => {
    const url = macOS.systemPreferences({ pane: 'com.apple.preferences.softwareupdate' })
    expect(url).toBe('x-apple.systempreferences:com.apple.preferences.softwareupdate')
  })

  test('helpViewer should return a URL without collection', async () => {
    const url = macOS.helpViewer()
    expect(url).toBe('x-apple-tips://')
  })

  test('helpViewer should return a URL with collection', async () => {
    const url = macOS.helpViewer({ collection: 'WelcomeToMac' })
    expect(url).toBe('x-apple-tips://open?collection=WelcomeToMac')
  })

  test('printer should return a URL without host', async () => {
    const url = macOS.printer()
    expect(url).toBe('ipp://')
  })

  test('printer should return a URL with host', async () => {
    const url = macOS.printer({ host: '192.168.1.100' })
    expect(url).toBe('ipp://192.168.1.100')
  })

  test('freeform should return a URL', async () => {
    const url = macOS.freeform()
    expect(url).toBe('freeform://')
  })

  test('airport should return a URL', async () => {
    const url = macOS.airport()
    expect(url).toBe('apconfig://')
  })

  test('dictionary should return a URL without term', async () => {
    const url = macOS.dictionary()
    expect(url).toBe('dict://')
  })

  test('dictionary should return a URL with term', async () => {
    const url = macOS.dictionary({ term: 'hello' })
    expect(url).toBe('dict://hello')
  })
})
