Skip to content

Commit e41df9a

Browse files
committed
Test for custom type check function
No Content-Type header passed in request, but since type function always returns true, its parsed as xml anyway
1 parent 96b6788 commit e41df9a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('XML Body Parser', function() {
5555
});
5656

5757
it('should accept xmlParseOptions', function(done) {
58-
createServer({
58+
createServer({
5959
xmlParseOptions: {
6060
normalize: true, // Trim whitespace inside text nodes
6161
normalizeTags: true, // Transform tags to lowercase
@@ -91,6 +91,16 @@ describe('XML Body Parser', function() {
9191
.expect(200, { parsed: { customer: { name: ['Bob'] } } }, done);
9292
});
9393

94+
it('should accept custom ContentType as function', function(done) {
95+
createServer({
96+
type: () => true
97+
});
98+
request(app)
99+
.post('/')
100+
.send('<customer><name>Bob</name></customer>')
101+
.expect(200, { parsed: { customer: { name: ['Bob'] } } }, done);
102+
});
103+
94104
it('should ignore non-XML', function(done) {
95105
createServer();
96106

0 commit comments

Comments
 (0)