/**
 * (happy / negative samples for email and password patterns).
 */
import { EMAIL_FORMAT_REGEX, EMAIL_REGEX, PASSWORD_REGEX } from '@/constants/regex'

describe('[constants/regex]', () => {
  describe('EMAIL_FORMAT_REGEX', () => {
    it('accepts typical email shape', () => {
      expect(EMAIL_FORMAT_REGEX.test('user@example.com')).toBe(true)
    })

    it('rejects non-email strings', () => {
      expect(EMAIL_FORMAT_REGEX.test('invalid')).toBe(false)
    })
  })

  describe('EMAIL_REGEX', () => {
    it('accepts valid local-part (no +) and domain', () => {
      expect(EMAIL_REGEX.test('user@example.com')).toBe(true)
      expect(EMAIL_REGEX.test('user.name-tag@company.co.uk')).toBe(true)
    })

    it('rejects malformed addresses', () => {
      expect(EMAIL_REGEX.test('invalid')).toBe(false)
      expect(EMAIL_REGEX.test('@nodomain.com')).toBe(false)
      expect(EMAIL_REGEX.test('user@')).toBe(false)
    })
  })

  describe('PASSWORD_REGEX', () => {
    it('accepts strong password (length, upper, lower, digit, special)', () => {
      expect(PASSWORD_REGEX.test('ValidPass1!')).toBe(true)
    })

    it('rejects whitespace inside password', () => {
      expect(PASSWORD_REGEX.test('Valid Pass1!')).toBe(false)
    })

    it('rejects password shorter than min complex length', () => {
      expect(PASSWORD_REGEX.test('Val1!')).toBe(false)
    })
  })
})
