Sha256: f88af16823668facb3afe11f06282bae929e76516295584e1b3322c2e0bdf2e4

Contents?: true

Size: 678 Bytes

Versions: 47

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

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

47 entries across 47 versions & 2 rubygems

Version Path
solidus_backend-2.10.5 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.10.3 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.10.2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.6 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.8.6 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.10.1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.5 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.10.0 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.4 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.6.6 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.7.4 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.8.5 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.3 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.2 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.10.0.beta1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.7.3 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.6.5 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.1 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.0 spec/features/admin/javascript_format_money_spec.rb
solidus_backend-2.9.0.rc.1 spec/features/admin/javascript_format_money_spec.rb