Sha256: 4b31ccd77f137e031d42f56f3ada0f2c81f6ffc40e29230832206e1fcffb7827

Contents?: true

Size: 784 Bytes

Versions: 10

Compression:

Stored size: 784 Bytes

Contents

require 'test_helper'

require 'chartjs/chart_helpers'

class ChartHelpersTest < Minitest::Test

  class Foo
    include Chartjs::ChartHelpers

    def to_js(element)
      to_javascript_string element
    end
  end

  def setup
    @subject = Foo.new
  end

  def test_to_javascript_string
    assert_equal '"foo"', @subject.to_js('foo')

    assert_equal '["a",42]', @subject.to_js(['a', 42])

    assert_equal '{"a":42}', @subject.to_js({'a' => 42})

    assert_equal '{"a":function(x) { blah; }}', @subject.to_js({'a' => 'function(x) { blah; }'})

    expected = \
'{"a":function(x) {
  if (x) {
    foo();
  }
  else {
    bar();
  }
}
}'

    assert_equal expected, @subject.to_js({'a' => <<END})
function(x) {
  if (x) {
    foo();
  }
  else {
    bar();
  }
}
END
  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
chartjs-ror-3.7.0 test/chart_helpers_test.rb
tracks-chartjs-ror-3.6.4 test/chart_helpers_test.rb
chartjs-ror-3.6.4 test/chart_helpers_test.rb
chartjs-ror-3.6.3 test/chart_helpers_test.rb
chartjs-ror-3.6.2 test/chart_helpers_test.rb
chartjs-ror-3.6.1 test/chart_helpers_test.rb
chartjs-ror-3.6.0 test/chart_helpers_test.rb
chartjs-ror-3.5.0 test/chart_helpers_test.rb
chartjs-ror-3.4.0 test/chart_helpers_test.rb
chartjs-ror-3.3.1 test/chart_helpers_test.rb