Sha256: 77bf6d797fadaa0ad83ddeaef281163daacca8c55d17b5b44c03da6ff7619798

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class KlarnaHelperTest < ViewTest
      def test_klarna_on_site_messaging_javacript_tag
        Workarea.config.klarna_on_site_messaging_client_id = nil
        assert_nil(klarna_on_site_messaging_javacript_tag)

        Workarea.config.klarna_on_site_messaging_client_id = '123'
        Workarea.config.klarna_on_site_messaging_region = 'NA'
        Workarea.config.klarna_playground = true

        result = klarna_on_site_messaging_javacript_tag
        assert_includes(result, %(src="https://na-library.playground.klarnaservices.com/lib.js"))
        assert_includes(result, %(async))
        assert_includes(result, %(data-client-id="123"))
        assert_includes(result, %(data-klarna-on-site-messaging))
      end


      def test_klarna_on_site_messaging_url
        Workarea.config.klarna_on_site_messaging_region = 'NA'
        Workarea.config.klarna_playground = true

        assert_equal(
          'https://na-library.playground.klarnaservices.com/lib.js',
          klarna_on_site_messaging_url
        )

        Workarea.config.klarna_playground = false
        assert_equal(
          'https://na-library.klarnaservices.com/lib.js',
          klarna_on_site_messaging_url
        )

        Workarea.config.klarna_on_site_messaging_region = 'EUR'
        assert_equal(
          'https://eu-library.klarnaservices.com/lib.js',
          klarna_on_site_messaging_url
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-klarna-1.1.0 test/helpers/workarea/storefront/klarna_helper_test.rb
workarea-klarna-1.1.0.beta1 test/helpers/workarea/storefront/klarna_helper_test.rb