-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support assertionExceptions without priority prefix
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Generates the assertionException string with a default priority prefix | ||
* @param {String} assertionException | ||
* @param {Number} defaultPriority | ||
* @returns {String} | ||
*/ | ||
function setDefaultAssertionException(assertionException, defaultPriority) { | ||
if (assertionException && !assertionException.includes(':')) { | ||
return `${defaultPriority}:${assertionException}`; | ||
} | ||
return assertionException; | ||
} | ||
|
||
/** | ||
* Finds the default assertion value for an assertionException without | ||
* a priority prefix in a string of assertionExceptions and recreates | ||
* the string with the new default assertion priorities | ||
* @param {String} assertionExceptions | ||
* @param {Array} assertions | ||
* @returns {String} | ||
*/ | ||
function setDefaultAssertionExceptionsFromTest(assertionExceptions, assertions) { | ||
return assertionExceptions | ||
.split(' ') | ||
.map(assertionException => { | ||
const assertion = assertions.find(assertion => | ||
assertionException.includes(assertion.assertionId) | ||
); | ||
if (assertion) { | ||
const defaultPriority = assertion.priority; | ||
return setDefaultAssertionException(assertionException, defaultPriority); | ||
} | ||
return assertionException; | ||
}) | ||
.join(' '); | ||
} | ||
|
||
exports.setDefaultAssertionExceptionsFromTest = setDefaultAssertionExceptionsFromTest; |