Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
108 lines
4.7 KiB
Ruby
108 lines
4.7 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe ContactHelper do
|
|
describe '#parse_name' do
|
|
it 'correctly splits a full name into first and last name' do
|
|
full_name = 'John Doe Smith'
|
|
expected_result = { first_name: 'John', last_name: 'Smith', middle_name: 'Doe', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles single-word names correctly' do
|
|
full_name = 'Cher'
|
|
expected_result = { first_name: 'Cher', last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles an empty string correctly' do
|
|
full_name = ''
|
|
expected_result = { first_name: nil, last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles multiple consecutive spaces correctly' do
|
|
full_name = 'John Doe Smith'
|
|
expected_result = { last_name: 'Smith', first_name: 'John', middle_name: 'Doe', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'returns nil for first and last name when input is nil' do
|
|
full_name = nil
|
|
expected_result = { first_name: nil, last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles names with special characters correctly' do
|
|
full_name = 'John Doe-Smith'
|
|
expected_result = { first_name: 'John', last_name: 'Doe-Smith', middle_name: '', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles non-Latin script names correctly' do
|
|
full_name = '李 小龙'
|
|
expected_result = { first_name: '李', last_name: '小龙', middle_name: '', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handle name with trailing spaces correctly' do
|
|
full_name = 'John Doe Smith '
|
|
expected_result = { first_name: 'John', last_name: 'Smith', middle_name: 'Doe', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handle name with leading spaces correctly' do
|
|
full_name = ' John Doe Smith'
|
|
expected_result = { first_name: 'John', last_name: 'Smith', middle_name: 'Doe', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handle name with phone number correctly' do
|
|
full_name = '+1234567890'
|
|
expected_result = { first_name: '+1234567890', last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handle name with mobile number with spaces correctly' do
|
|
full_name = '+1 234 567 890'
|
|
expected_result = { first_name: '+1 234 567 890', last_name: nil, middle_name: nil, prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'correctly splits a full name with middle name' do
|
|
full_name = 'John Quincy Adams'
|
|
expected_result = { first_name: 'John', last_name: 'Adams', middle_name: 'Quincy', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles names with multiple spaces between first and last name' do
|
|
full_name = 'John Quincy Adams'
|
|
expected_result = { first_name: 'John', last_name: 'Adams', middle_name: 'Quincy', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles names with leading and trailing whitespaces' do
|
|
full_name = ' John Quincy Adams '
|
|
expected_result = { first_name: 'John', last_name: 'Adams', middle_name: 'Quincy', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles names with leading and trailing whitespaces and a middle initial' do
|
|
full_name = ' John Q. Adams '
|
|
expected_result = { first_name: 'John', last_name: 'Adams', middle_name: 'Q.', prefix: nil, suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles names with a prefix' do
|
|
full_name = 'Mr. John Doe'
|
|
expected_result = { first_name: 'John', last_name: 'Doe', middle_name: '', prefix: 'Mr.', suffix: nil }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
|
|
it 'handles names with a suffix' do
|
|
full_name = 'John Doe Jr.'
|
|
expected_result = { first_name: 'John', last_name: 'Doe', middle_name: '', prefix: nil, suffix: 'Jr.' }
|
|
expect(helper.parse_name(full_name)).to eq(expected_result)
|
|
end
|
|
end
|
|
end
|