Sha256: 57c5369626091846c5e73fe522f76abee5c9aed42b0ab800b66502e4e5fa2ade

Contents?: true

Size: 1.96 KB

Versions: 9

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'helper'

class TestPhoneNumberID < Test::Unit::TestCase
  include DeterministicHelper

  assert_methods_are_deterministic(
    FFaker::PhoneNumberID,
    :mobile_phone_number,
    :home_phone_number,
    :phone_number
  )

  def setup
    @tester = FFaker::PhoneNumberID
  end

  def test_mobile_phone_number
    prefixes = FFaker::PhoneNumberID::MOBILE_PHONE_PREFIXES
    regex = /\A(?:#{prefixes.join('|')})-\d{8}\z/
    assert_match regex, FFaker::PhoneNumberID.mobile_phone_number
  end

  def test_home_phone_number
    prefixes = FFaker::PhoneNumberID::HOME_PHONE_PREFIXES
    regex = /\A(#{prefixes.join('|')})-(\d{7,8})\z/
    assert_match regex, FFaker::PhoneNumberID.home_phone_number
  end

  def test_phone_number
    mobile_prefixes = FFaker::PhoneNumberID::MOBILE_PHONE_PREFIXES
    home_prefixes = FFaker::PhoneNumberID::HOME_PHONE_PREFIXES
    regex = /\A(#{mobile_prefixes.join('|')}|#{home_prefixes.join('|')})-(\d{7,8})\z/
    assert_match regex, FFaker::PhoneNumberID.phone_number
  end

  def test_international_mobile_phone_number
    prefixes = FFaker::PhoneNumberID::MOBILE_PHONE_PREFIXES.map { |x| x.sub('0', '') }
    regex = /\A\+62(#{prefixes.join('|')})-(\d{8})\z/
    assert_match regex, FFaker::PhoneNumberID.international_mobile_phone_number
  end

  def test_international_home_phone_number
    prefixes = FFaker::PhoneNumberID::HOME_PHONE_PREFIXES.map { |x| x.sub('0', '') }
    regex = /\A\+62(#{prefixes.join('|')})-(\d{7,8})\z/
    assert_match regex, FFaker::PhoneNumberID.international_home_phone_number
  end

  def test_international_phone_number
    mobile_prefixes = FFaker::PhoneNumberID::MOBILE_PHONE_PREFIXES.map { |x| x.sub('0', '') }
    home_prefixes = FFaker::PhoneNumberID::HOME_PHONE_PREFIXES.map { |x| x.sub('0', '') }
    regex = /\A\+62(#{mobile_prefixes.join('|')}|#{home_prefixes.join('|')})-(\d{7,8})\z/

    assert_match regex, FFaker::PhoneNumberID.international_phone_number
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffaker-2.11.0 test/test_phone_number_id.rb
ffaker-2.10.0 test/test_phone_number_id.rb
ffaker-2.9.0 test/test_phone_number_id.rb
ffaker-2.8.1 test/test_phone_number_id.rb
ffaker-2.8.0 test/test_phone_number_id.rb
ffaker-2.7.0 test/test_phone_number_id.rb
ffaker-2.6.0 test/test_phone_number_id.rb
ffaker-2.5.0 test/test_phone_number_id.rb
ffaker-2.4.0 test/test_phone_number_id.rb