Skip to content

Commit 384fac1

Browse files
committed
Add test for a link with data-remote attribute and data-params as JSON
1 parent 92af43f commit 384fac1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/public/test/data-remote.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@ asyncTest('clicking on a link with data-remote attribute', 5, function() {
8484
.trigger('click');
8585
});
8686

87+
asyncTest('clicking on a link with data-remote attribute and data-params as JSON', 6, function() {
88+
var value1 = 0,
89+
value2 = '\'quoted"/>&<\'value"',
90+
value3 = {foo: {bar: {baz: value2}}},
91+
params = {
92+
data1: value1,
93+
data2: value2,
94+
data3: value3
95+
};
96+
$('a[data-remote]')
97+
.attr('data-params', JSON.stringify(params))
98+
.bind('ajax:success', function(e, data, status, xhr) {
99+
App.assertCallbackInvoked('ajax:success');
100+
App.assertRequestPath(data, '/echo');
101+
equal(data.params.data1, value1, 'params should have key data1 with right value');
102+
equal(data.params.data2, value2, 'params should have key data2 with right value');
103+
propEqual(data.params.data3, {foo: {bar: {baz: value2}}}, 'params should have key data3 with right value');
104+
App.assertGetRequest(data);
105+
})
106+
.bind('ajax:complete', function() { start() })
107+
.trigger('click');
108+
});
109+
87110
asyncTest('clicking on a button with data-remote attribute', 5, function() {
88111
$('button[data-remote]')
89112
.bind('ajax:success', function(e, data, status, xhr) {

0 commit comments

Comments
 (0)