Skip to content

Commit

Permalink
Add test for accepting array as parameter based on wsdl (#933)
Browse files Browse the repository at this point in the history
v. 0.19.0 broke giving array as a parameter. It would now accept the "array"
with invalid syntax like this: {input: {PeriodList: {"PeriodType[]": {PeriodId: '1'}}}}
i.e. it wants the "[]" as the parameter name and it does not accept an array, but an
object. The invalid syntax then prints invalid XML like this:
"<PeriodList><PeriodType[]><PeriodId>1</PeriodId></PeriodType[]></PeriodList>"

This test shows old and correct syntax.

This test passes if you revert commit 5dbcb1d
or disable if statement mentioned in
#914 (review)
  • Loading branch information
pihvi authored and herom committed May 29, 2017
1 parent 358c611 commit 94a8b54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,20 @@ var fs = require('fs'),
done();
});
});

it('shall generate correct payload for methods with array parameter', function(done) {
soap.createClient(__dirname + '/wsdl/list_parameter.wsdl', function(err, client) {
assert.ok(client);
var pathToArrayContainer = 'TimesheetV201511Mobile.TimesheetV201511MobileSoap.AddTimesheet.input.input.PeriodList';
var arrayParameter = _.get(client.describe(), pathToArrayContainer)['PeriodType[]'];
assert.ok(arrayParameter);
client.AddTimesheet({input: {PeriodList: {PeriodType: [{PeriodId: '1'}]}}}, function() {
var sentInputContent = client.lastRequest.substring(client.lastRequest.indexOf('<input>') + '<input>'.length, client.lastRequest.indexOf('</input>'));
assert.equal(sentInputContent, '<PeriodList><PeriodType><PeriodId>1</PeriodId></PeriodType></PeriodList>');
done();
});
});
});
});
});
});
Loading

0 comments on commit 94a8b54

Please # to comment.