Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Commit

Permalink
Fix #6: ResponseAssertion on status equality to use integer
Browse files Browse the repository at this point in the history
  • Loading branch information
robingustafsson committed Feb 27, 2019
1 parent 5535e91 commit fd9c04e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/element/ResponseAssertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ function completeString (test, settings) {
`Object.values(${settings.operand})` +
`.includes(${JSON.stringify(test)})`
)
} else return `${settings.operand} === ${JSON.stringify(test)}`
} else if (/status$/.test(settings.operand)) {
return `${settings.operand} === ${parseInt(test)}`
} else {
return `${settings.operand} === ${JSON.stringify(test)}`
}
}

function partialString (test, settings) {
Expand Down
18 changes: 18 additions & 0 deletions test/int/element/ResponseAssertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ test('equal field', t => {
})
})

test('equal status', t => {
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<ResponseAssertion>
<stringProp name="test_field">response_code</stringProp>
<intProp name="test_type">8</intProp>
<collectionProp name="test_strings">
<stringProp>200</stringProp>
</collectionProp>
</ResponseAssertion>
`
const tree = parseXml(xml)
const node = tree.children[0]
const result = ResponseAssertion(node)
t.deepEqual(result.defaults[0][Check], {
'ResponseAssertion': 'return (r.status === 200)'
})
})

test('equal header', t => {
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<ResponseAssertion>
Expand Down

0 comments on commit fd9c04e

Please sign in to comment.