Skip to content

Commit 31840e7

Browse files
committed
Test array form data with multiple values
1 parent fe20697 commit 31840e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/unit/pjax_fallback.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,21 @@ asyncTest("GET with data array"+s, function() {
318318

319319
this.loaded = function() {
320320
equal(frame.location.pathname, "/env.html")
321-
equal(frame.location.search, "?foo=bar")
321+
equal(frame.location.search, "?foo%5B%5D=bar&foo%5B%5D=baz")
322322

323323
var env = JSON.parse(frame.$("#env").text())
324324
equal(env['REQUEST_METHOD'], "GET")
325-
equal(env['rack.request.query_hash']['foo'], 'bar')
325+
var expected = {'foo': ['bar', 'baz']};
326+
if (!disabled) expected._pjax = "#main"
327+
deepEqual(env['rack.request.query_hash'], expected)
326328

327329
start()
328330
}
329331

330332
frame.$.pjax({
331333
type: 'GET',
332334
url: "env.html",
333-
data: [{name: "foo", value: "bar"}],
335+
data: [{name: "foo[]", value: "bar"}, {name: "foo[]", value: "baz"}],
334336
container: "#main"
335337
})
336338
})
@@ -344,15 +346,17 @@ asyncTest("POST with data array"+s, function() {
344346

345347
var env = JSON.parse(frame.$("#env").text())
346348
equal(env['REQUEST_METHOD'], "POST")
347-
equal(env['rack.request.form_hash']['foo'], 'bar')
349+
var expected = {'foo': ['bar', 'baz']};
350+
if (!disabled) expected._pjax = "#main"
351+
deepEqual(env['rack.request.form_hash'], expected)
348352

349353
start()
350354
}
351355

352356
frame.$.pjax({
353357
type: 'POST',
354358
url: "env.html",
355-
data: [{name: "foo", value: "bar"}],
359+
data: [{name: "foo[]", value: "bar"}, {name: "foo[]", value: "baz"}],
356360
container: "#main"
357361
})
358362
})

0 commit comments

Comments
 (0)