package com.prodhack.moscow2025.data.data_providers

import org.junit.Test
import org.junit.Assert.*

class PhoneNumberPatternsProviderTest {

	@Test
	fun `phoneNumberPatterns is not empty`() {
		assertTrue(PhoneNumberPatternsProvider.phoneNumberPatterns.isNotEmpty())
	}

	@Test
	fun `phoneNumberPatterns contains Russia`() {
		val russia = PhoneNumberPatternsProvider.phoneNumberPatterns.find {
			it.countryCodeISO == "RU"
		}
		assertNotNull(russia)
		assertEquals("+7", russia?.countryCode)
		assertEquals("+7 Россия", russia?.name)
	}

	@Test
	fun `phoneNumberPatterns contains USA`() {
		val usa = PhoneNumberPatternsProvider.phoneNumberPatterns.find {
			it.countryCodeISO == "US"
		}
		assertNotNull(usa)
		assertEquals("+1", usa?.countryCode)
	}

	@Test
	fun `phoneNumberPatterns contains unique country codes`() {
		val countryCodes = PhoneNumberPatternsProvider.phoneNumberPatterns.map { it.countryCodeISO }
		val uniqueCodes = countryCodes.toSet()
		// Some countries may share country codes (like +1), but ISO codes should be mostly unique
		assertTrue(uniqueCodes.size > 0)
	}

	@Test
	fun `all patterns have valid structure`() {
		PhoneNumberPatternsProvider.phoneNumberPatterns.forEach { pattern ->
			assertTrue(pattern.name.isNotBlank())
			assertTrue(pattern.countryCode.isNotBlank())
			assertTrue(pattern.pattern.isNotBlank())
			assertTrue(pattern.countryCodeISO.isNotBlank())
			assertTrue(pattern.countryCode.startsWith("+"))
		}
	}

	@Test
	fun `patterns contain digit placeholders`() {
		PhoneNumberPatternsProvider.phoneNumberPatterns.forEach { pattern ->
			// Pattern should contain '0' as placeholder
			assertTrue(pattern.pattern.contains('0'))
		}
	}
}

