2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-09-22 16:04:57 +02:00
|
|
|
describe Champs::IbanChamp do
|
|
|
|
describe '#valid?' do
|
2024-07-01 15:31:32 +02:00
|
|
|
let(:champ) { Champs::IbanChamp.new(dossier: build(:dossier)) }
|
2024-09-20 14:54:26 +02:00
|
|
|
before do
|
|
|
|
allow(champ).to receive(:type_de_champ).and_return(build(:type_de_champ_iban))
|
|
|
|
allow(champ).to receive(:in_dossier_revision?).and_return(true)
|
|
|
|
end
|
2024-07-01 15:31:32 +02:00
|
|
|
def with_value(value)
|
|
|
|
champ.tap { _1.value = value }
|
|
|
|
end
|
2020-09-22 16:04:57 +02:00
|
|
|
it do
|
2024-07-01 15:31:32 +02:00
|
|
|
expect(with_value(nil).valid?(:champs_public_value)).to be_truthy
|
|
|
|
expect(with_value("FR35 KDSQFDJQSMFDQMFDQ").valid?(:champs_public_value)).to be_falsey
|
|
|
|
expect(with_value("FR7630006000011234567890189").valid?(:champs_public_value)).to be_truthy
|
|
|
|
expect(with_value("FR76 3000 6000 0112 3456 7890 189").valid?(:champs_public_value)).to be_truthy
|
|
|
|
expect(with_value("FR76 3000 6000 0112 3456 7890 189DSF").valid?(:champs_public_value)).to be_falsey
|
|
|
|
expect(with_value("FR76 3000 6000 0112 3456 7890 189").valid?(:champs_public_value)).to be_truthy
|
2022-10-06 15:49:34 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'format value after validation' do
|
2024-07-01 15:31:32 +02:00
|
|
|
with_value("FR76 3000 6000 0112 3456 7890 189")
|
2023-10-26 16:02:23 +02:00
|
|
|
champ.valid?(:champs_public_value)
|
2022-10-06 15:49:34 +02:00
|
|
|
expect(champ.value).to eq("FR76 3000 6000 0112 3456 7890 189")
|
2020-09-22 16:04:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|