Sha256: 1aecbaca701b906ea61b231456145893c1a5f72f911d00c7ccf37593e3507972

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Valvat::Checksum::ES do
  %w[ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980
     ESY3860557K ESY2207765D].each do |valid_vat|
    it "returns true on valid VAT #{valid_vat}" do
      expect(Valvat::Checksum.validate(valid_vat)).to be(true)
    end

    invalid_vat = "#{valid_vat[0..-6]}#{valid_vat[-2]}#{valid_vat[-5]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-1]}"

    it "returns false on invalid VAT #{invalid_vat}" do
      expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
    end
  end

  describe 'if starts with [KLMXYZ\\d], is always a natural person' do
    invalid_vat = 'ESX65474207'
    it "returns false on invalid VAT #{invalid_vat}" do
      expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
valvat-1.1.5 spec/valvat/checksum/es_spec.rb