Sha256: 10150991969257cb442e9f397def395db39b8579c6fb8347064f414f307b9412

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

require_relative 'helper'

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

  assert_methods_are_deterministic(FFaker::Code, :ean, :npi)

  def test_npi_legacy_regexp
    assert FFaker::Code.npi(legacy: true).match(/\A(1|2)[0-9]{9}\z/)
  end

  def test_npi
    FFaker::Random.seed = 523_456_789
    assert FFaker::Code.npi == '7411850515'
  end

  def test_deterministic_npi
    FFaker::Random.seed = 42
    v = FFaker::Code.npi
    FFaker::Random.reset!
    assert v == FFaker::Code.npi
  end

  def test_valid_npi
    FFaker::Random.seed = 123_456_789
    assert FFaker::Code.npi == '2410167607'
  end

  def test_ean
    assert FFaker::Code.ean.match(/^\d{13}$/)
  end

  def test_ean_deterministic
    FFaker::Random.seed = 10
    assert_equal FFaker::Code.ean, '1399378750693'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ffaker-2.23.0 test/test_code.rb
ffaker-2.22.0 test/test_code.rb
ffaker-2.21.0 test/test_code.rb
ffaker-2.20.0 test/test_code.rb
ffaker-2.19.0 test/test_code.rb