Sha256: 10ea62293f24d979a1c9123b9f3e85cbdb2b5427f26e4b1cee566b5b73dfe41c

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Roqua::Healthy::A19::PhoneParser do
  subject { described_class.new(message).to_s }

  describe 'otherwise valid phone number with extra comment at the end' do
    let(:message) { {'PID' => {'PID.13' => [{'PID.13.1' => '0612345678 moeder', 'PID.13.2' => 'PRN'}]}} }
    it { should be_nil }
  end

  describe 'valid phone number' do
    let(:message) { {'PID' => {'PID.13' => [{'PID.13.1' => '0612345678', 'PID.13.2' => 'PRN'}]}} }
    it { should eq('0612345678') }
  end

  describe 'non-mobile type number in PRN, mobile type in another' do
    let(:message) do
      {'PID' => {'PID.13' => [{'PID.13.1' => '0502345678', 'PID.13.2' => 'PRN'},
                              {'PID.13.1' => '0612345678', 'PID.13.2' => 'CP'}]}}
    end
    it { should eq('0612345678') }
  end

  describe 'only non-mobile type numbers' do
    let(:message) do
      {'PID' => {'PID.13' => [{'PID.13.1' => '0502345678', 'PID.13.2' => 'PRN'},
                              {'PID.13.1' => '0502345679', 'PID.13.2' => 'CP'}]}}
    end
    it { should be_nil }
  end

  describe 'mobile type in PRN is preferred over other mobile numbers' do
    let(:message) do
      {'PID' => {'PID.13' => [{'PID.13.1' => '0612345678', 'PID.13.2' => 'CP'},
                              {'PID.13.1' => '0612345679', 'PID.13.2' => 'PRN'}]}}
    end
    it { should eq('0612345679') }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roqua-healthy-1.5.10 spec/unit/a19/phone_parser_spec.rb
roqua-healthy-1.5.9 spec/unit/a19/phone_parser_spec.rb
roqua-healthy-1.5.8 spec/unit/a19/phone_parser_spec.rb
roqua-healthy-1.5.7 spec/unit/a19/phone_parser_spec.rb
roqua-healthy-1.5.6 spec/unit/a19/phone_parser_spec.rb