Sha256: 3ae02b4264ba3e08da9bc8e6fd11b0805c05a44b7e79be67968a5b7b87301824

Contents?: true

Size: 647 Bytes

Versions: 22

Compression:

Stored size: 647 Bytes

Contents

require 'spec_helper'

RSpec.describe 'JS Spree.formatMoney', js: true do
  stub_authorization!

  # This is a slightly hacky spec to ensure that our JS will format money in
  # the same was as our ruby code.
  # This should probably replaced with a pure JS test in the future.
  it 'should behave identically to Spree::Money#to_s' do
    visit '/admin'

    Money::Currency.all.map(&:id).map(&:to_s).map(&:upcase).uniq.each do |currency|
      money = Spree::Money.new(1234, currency: currency)

      js_result = page.evaluate_script("Spree.formatMoney(#{money.to_d}, '#{currency}')")

      expect(js_result).to eq money.to_s
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
solidus_backend-2.5.2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.5.1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.5.0 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.5.0.rc1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.5.0.beta2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.5.0.beta1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.4.2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.4.1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.3.1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.2.2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.4.0 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.4.0.rc1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.4.0.beta1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.3.0 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.3.0.rc3 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.3.0.rc2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.3.0.rc1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.3.0.beta1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.2.1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.2.0 spec/features/admin/javascript_format_money_spec.rb