Merge pull request #10886 from BerkeleyTrue/feat/test-object

Feat(challenges): Let tests be objects
This commit is contained in:
Quincy Larson
2016-09-26 11:03:22 -07:00
committed by GitHub
2 changed files with 13 additions and 5 deletions

View File

@ -35,10 +35,15 @@ export function getFileKey({ challengeType }) {
export function createTests({ tests = [] }) {
return tests
.map(test => ({
text: ('' + test).split('message: ').pop().replace(/\'\);/g, ''),
testString: test
}));
.map(test => {
if (typeof tests === 'string') {
return {
text: ('' + test).split('message: ').pop().replace(/\'\);/g, ''),
testString: test
};
}
return test;
});
}
export function loggerToStr(args) {

View File

@ -24,7 +24,10 @@
"<h1>Hello</h1>"
],
"tests": [
"assert.isTrue((/hello(\\s)+world/gi).test($('h1').text()), 'message: Your <code>h1</code> element should have the text \"Hello World\".');"
{
"text": "Your <code>h1</code> element should have the text \"Hello World\".');",
"testString": "assert.isTrue((/hello(\\s)+world/gi).test($('h1').text()), 'Your <code>h1</code> element should have the text \"Hello World\".');"
}
],
"type": "waypoint",
"challengeType": 0,