import { test } from '@japa/runner'
import { UrlEncoder } from '../../../src/lib/parsers/UrlEncoder.js'

test.group('encodeQueryString()', () => {
  test('Returns empty string when argument is empty', ({ assert }) => {
    const result = UrlEncoder.encodeQueryString('', true)
    assert.equal(result, '')
  })

  test('Returns empty string when argument is empty', ({ assert }) => {
    const result = UrlEncoder.encodeQueryString('', true)
    assert.equal(result, '')
  })

  test('URL encodes string', ({ assert }) => {
    const result = UrlEncoder.encodeQueryString(';This / is? &test:= + $ , #', true)
    assert.equal(result, '%3BThis+%2F+is%3F+%26test%3A%3D+%2B+%24+%2C+%23')
  })
})

test.group('decodeQueryString()', () => {
  test('Returns empty string when argument is empty', ({ assert }) => {
    const result = UrlEncoder.decodeQueryString('', true)
    assert.equal(result, '')
  })

  test('Returns empty string when argument is empty', ({ assert }) => {
    const result = UrlEncoder.decodeQueryString('', true)
    assert.equal(result, '')
  })

  test('URL encodes string', ({ assert }) => {
    const result = UrlEncoder.decodeQueryString('%3BThis+%2F+is%3F+%26test%3A%3D+%2B+%24+%2C+%23', true)
    assert.equal(result, ';This / is? &test:= + $ , #')
  })
})
