Sha256: 6c9c58e46935c38285b015fc5dac16bce428fbcf792cbe26f5d86f61c6442322

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

require "spec_helper"

describe JsRoutes, "#serialize" do

  before(:each) do
    evaljs(JsRoutes.generate({module_type: nil}))
  end

  it "should provide this method" do
    expect(evaljs("Routes.serialize({a: 1, b: [2,3], c: {d: 4, e: 5}, f: ''})")).to eq(
      "a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5&f="
    )
  end

  it "should provide this method" do
    expect(evaljs("Routes.serialize({a: 1, b: [2,3], c: {d: 4, e: 5}, f: ''})")).to eq(
      "a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5&f="
    )
  end

  it "works with JS suckiness" do
    expect(evaljs(
      [
        "const query = Object.create(null);",
        "query.a = 1;",
        "query.b = 2;",
        "Routes.serialize(query);",
      ].join("\n")
    )).to eq("a=1&b=2")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
js-routes-2.0.5 spec/js_routes/default_serializer_spec.rb
js-routes-2.0.4 spec/js_routes/default_serializer_spec.rb
js-routes-2.0.3 spec/js_routes/default_serializer_spec.rb
js-routes-2.0.2 spec/js_routes/default_serializer_spec.rb
js-routes-2.0.1 spec/js_routes/default_serializer_spec.rb