Files
Laca-City/backend/node_modules/libphonenumber-js/source/helpers/extractPhoneContext.test.js
PhongPham c65cc97a33 🎯 MapView v2.0 - Global Deployment Ready
 MAJOR FEATURES:
• Auto-zoom intelligence với smart bounds fitting
• Enhanced 3D GPS markers với pulsing effects
• Professional route display với 6-layer rendering
• Status-based parking icons với availability indicators
• Production-ready build optimizations

🗺️ AUTO-ZOOM FEATURES:
• Smart bounds fitting cho GPS + selected parking
• Adaptive padding (50px) cho visual balance
• Max zoom control (level 16) để tránh quá gần
• Dynamic centering khi không có selection

🎨 ENHANCED VISUALS:
• 3D GPS marker với multi-layer pulse effects
• Advanced parking icons với status colors
• Selection highlighting với animation
• Dimming system cho non-selected items

🛣️ ROUTE SYSTEM:
• OpenRouteService API integration
• Multi-layer route rendering (glow, shadow, main, animated)
• Real-time distance & duration calculation
• Visual route info trong popup

📱 PRODUCTION READY:
• SSR safe với dynamic imports
• Build errors resolved
• Global deployment via Vercel
• Optimized performance

🌍 DEPLOYMENT:
• Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app
• Bundle size: 22.8 kB optimized
• Global CDN distribution
• HTTPS enabled

💾 VERSION CONTROL:
• MapView-v2.0.tsx backup created
• MAPVIEW_VERSIONS.md documentation
• Full version history tracking
2025-07-20 19:52:16 +07:00

104 lines
3.5 KiB
JavaScript

import parsePhoneNumber_ from '../parsePhoneNumber.js'
import PhoneNumber from '../PhoneNumber.js'
import metadata from '../../metadata.min.json' assert { type: 'json' }
function parsePhoneNumber(...parameters) {
parameters.push(metadata)
return parsePhoneNumber_.apply(this, parameters)
}
describe('extractPhoneContext', function() {
it('should parse RFC 3966 phone number URIs', function() {
// context = ";phone-context=" descriptor
// descriptor = domainname / global-number-digits
const NZ_NUMBER = new PhoneNumber('64', '33316005', metadata)
// Valid global-phone-digits
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+64'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+64;{this isn\'t part of phone-context anymore!}'),
NZ_NUMBER
)
const nzFromPhoneContext = new PhoneNumber('64', '3033316005', metadata)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+64-3'),
nzFromPhoneContext
)
const brFromPhoneContext = new PhoneNumber('55', '5033316005', metadata)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+(555)'),
brFromPhoneContext
)
const usFromPhoneContext = new PhoneNumber('1', '23033316005', metadata)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+-1-2.3()'),
usFromPhoneContext
)
// Valid domainname.
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=abc.nz', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=www.PHONE-numb3r.com', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=a', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=3phone.J.', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=a--z', 'NZ'),
NZ_NUMBER
)
// Should strip ISDN subaddress.
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;isub=/@;phone-context=+64', 'NZ'),
NZ_NUMBER
)
// // Should support incorrectly-written RFC 3966 phone numbers:
// // the ones written without a `tel:` prefix.
// expectPhoneNumbersToBeEqual(
// parsePhoneNumber('033316005;phone-context=+64', 'NZ'),
// NZ_NUMBER
// )
// Invalid descriptor.
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=+')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=64')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=++64')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=+abc')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=.')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=3phone')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=a-.nz')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=a{b}c')
})
})
function expectToThrowForInvalidPhoneContext(string) {
expect(parsePhoneNumber(string)).to.be.undefined
}
function expectPhoneNumbersToBeEqual(phoneNumber1, phoneNumber2) {
if (!phoneNumber1 || !phoneNumber2) {
return false
}
return phoneNumber1.number === phoneNumber2.number &&
phoneNumber1.ext === phoneNumber2.ext
}