Sha256: dcfe5ec714651f494ece3d8d2a73d4cd9f26307729c7dfc1938ff8a7bfd2af8b
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' describe Valvat::Utils do context "#split" do it "returns country and rest on vat number as array" do Valvat::Utils.split("DE345889003").should eql(["DE", "345889003"]) Valvat::Utils.split("ESX4588900X").should eql(["ES", "X4588900X"]) end it "returns two nils on non-european iso codes as array" do Valvat::Utils.split("US345889003").should eql([nil, nil]) Valvat::Utils.split("RUX4588900X").should eql([nil, nil]) end it "returns two nils on non-sense input as array" do Valvat::Utils.split("DE").should eql([nil, nil]) Valvat::Utils.split("X345889003").should eql([nil, nil]) Valvat::Utils.split("").should eql([nil, nil]) Valvat::Utils.split("1234").should eql([nil, nil]) Valvat::Utils.split(" ").should eql([nil, nil]) end it "returns GR on greek vat" do Valvat::Utils.split("EL999999999").should eql(["GR", "999999999"]) end end context "#normalize" do it "returns vat number with upcase chars" do Valvat::Utils.normalize("de345889003").should eql("DE345889003") Valvat::Utils.normalize("EsX4588900y").should eql("ESX4588900Y") end it "returns trimmed vat number" do Valvat::Utils.normalize(" DE345889003").should eql("DE345889003") Valvat::Utils.normalize(" DE345889003 ").should eql("DE345889003") Valvat::Utils.normalize("DE345889003 ").should eql("DE345889003") end it "dors not change already normalized vat numbers" do Valvat::Utils.normalize("DE345889003").should eql("DE345889003") Valvat::Utils.normalize("ESX4588900X").should eql("ESX4588900X") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
valvat-0.1.1 | spec/valvat/utils_spec.rb |
valvat-0.1.0 | spec/valvat/utils_spec.rb |