Sha256: b080557fde107004530cf7857c19b905c77c6a105d2961c610ca75728e975cbc

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe LazyHighCharts::OptionsKeyFilter do
  it "should filter :pointInterval from seconds to milliseconds" do
    hash = LazyHighCharts::OptionsKeyFilter.filter(pointInterval: 1)
    expect(hash[:pointInterval]).to eq(1000)
  end

  describe "filters :pointStart from a Date to a JavaScript compatible string" do
    before(:each) do
      hash = LazyHighCharts::OptionsKeyFilter.filter(pointStart: Date.new(2012, 9, 13))
      @value = hash[:pointStart]
    end

    it "should be the correct string" do
      expect(@value).to eq("Date.UTC(2012, 8, 13)")
    end

    it "should be js_code" do
      expect(@value.js_code).to be_truthy
    end
  end

  it "should filter keys recursively" do
    hash = LazyHighCharts::OptionsKeyFilter.filter({something: {another_thing: {pointInterval: 2}}})
    expect(hash[:something][:another_thing][:pointInterval]).to eq(2000)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazy_high_charts-1.6.1 spec/options_key_filter_spec.rb
lazy_high_charts-1.5.8 spec/options_key_filter_spec.rb
lazy_high_charts-1.5.6 spec/options_key_filter_spec.rb
lazy_high_charts-1.5.5 spec/options_key_filter_spec.rb