Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for parsing of doubles and floats. #1065

Merged
merged 2 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/wsdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ export class WSDL {
} else {
if (name === 'int' || name === 'integer') {
value = parseInt(text, 10);
} else if (name === 'double' || name === 'float') {
value = Number(text);
} else if (name === 'bool' || name === 'boolean') {
value = text.toLowerCase() === 'true' || text === '1';
} else if (name === 'dateTime' || name === 'date') {
Expand Down
15 changes: 8 additions & 7 deletions test/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.service = {
}
};
} else {
return { price: 19.56 };
return { price: 19.56, tax: -1.23 };
}
},

Expand Down Expand Up @@ -256,7 +256,7 @@ describe('SOAP Server', function() {
soap.createClient(test.baseUrl + '/stockquote?wsdl', function(err, client) {
assert.ifError(err);
var description = client.describe(),
expected = { input: { tickerSymbol: "string" }, output:{ price: "float" } };
expected = { input: { tickerSymbol: "string" }, output:{ price: "float", tax: "double" } };
assert.deepEqual(expected , description.StockQuoteService.StockQuotePort.GetLastTradePrice);
done();
});
Expand All @@ -267,7 +267,8 @@ describe('SOAP Server', function() {
assert.ifError(err);
client.GetLastTradePrice({ tickerSymbol: 'AAPL'}, function(err, result) {
assert.ifError(err);
assert.equal(19.56, parseFloat(result.price));
assert.strictEqual(19.56, result.price); // float
assert.strictEqual(-1.23, result.tax); // double
done();
});
});
Expand All @@ -278,7 +279,7 @@ describe('SOAP Server', function() {
assert.ifError(err);
client.GetLastTradePrice({ tickerSymbol: 'Async'}, function(err, result) {
assert.ifError(err);
assert.equal(19.56, parseFloat(result.price));
assert.strictEqual(19.56, result.price);
done();
});
});
Expand All @@ -301,7 +302,7 @@ describe('SOAP Server', function() {
assert.ifError(err);
client.GetLastTradePrice({ tickerSymbol: 'Promise'}, function(err, result) {
assert.ifError(err);
assert.equal(13.76, parseFloat(result.price));
assert.strictEqual(13.76, result.price);
done();
});
});
Expand Down Expand Up @@ -349,7 +350,7 @@ describe('SOAP Server', function() {
client.addSoapHeader('<SomeToken>123.45</SomeToken>');
client.GetLastTradePrice({ tickerSymbol: 'AAPL'}, function(err, result) {
assert.ifError(err);
assert.equal(123.45, parseFloat(result.price));
assert.strictEqual(123.45, result.price);
done();
});
});
Expand Down Expand Up @@ -388,7 +389,7 @@ describe('SOAP Server', function() {
client.addSoapHeader('<SomeToken>123.45</SomeToken>');
client.GetLastTradePrice({ tickerSymbol: 'AAPL'}, function(err, result) {
assert.ifError(err);
assert.equal(0, parseFloat(result.price));
assert.strictEqual(0, result.price);
done();
});
});
Expand Down
1 change: 1 addition & 0 deletions test/wsdl/strict/stockquote.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<xsd:complexType>
<xsd:all>
<xsd:element name="price" type="float"/>
<xsd:element name="tax" type="double"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
Expand Down