Sha256: 95cfebdbb1dac00ba6ceb45154163f9f5c0233ed051d0c2513033f2c464804c7

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

require "spec_helper"

describe JsRoutes, "#serialize" do

  before(:each) do
    evaljs(JsRoutes.generate(module_type: nil, namespace: 'Routes'))
  end

  it "should provide this method" do
    expectjs("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
    expectjs("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
    expectjs(
      [
        "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

3 entries across 3 versions & 1 rubygems

Version Path
js-routes-2.2.7 spec/js_routes/default_serializer_spec.rb
js-routes-2.2.6 spec/js_routes/default_serializer_spec.rb
js-routes-2.2.5 spec/js_routes/default_serializer_spec.rb