Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--progtest/src/reader/YamlTestReader.js2
-rw-r--r--progtest/test/reader/YamlTestReaderTest.js10
2 files changed, 11 insertions, 1 deletions
diff --git a/progtest/src/reader/YamlTestReader.js b/progtest/src/reader/YamlTestReader.js
index a28c1f3..dc0ef3b 100644
--- a/progtest/src/reader/YamlTestReader.js
+++ b/progtest/src/reader/YamlTestReader.js
@@ -71,7 +71,7 @@ module.exports = Class( 'YamlTestReader' )
*/
'virtual public loadCases'( yaml )
{
- const data = this._yamlParser.safeLoad( yaml )
+ const data = ( this._yamlParser.safeLoad( yaml ) || [] )
.map( this._createTestCase );
return data;
diff --git a/progtest/test/reader/YamlTestReaderTest.js b/progtest/test/reader/YamlTestReaderTest.js
index 9fb26fd..bddc211 100644
--- a/progtest/test/reader/YamlTestReaderTest.js
+++ b/progtest/test/reader/YamlTestReaderTest.js
@@ -52,4 +52,14 @@ describe( "YamlTestReader", () =>
expect( Sut( mock_parser, case_ctor ).loadCases( yaml ) )
.to.deep.equal( [ { ok: parsed[0] } ] );
} );
+
+
+ it( "produces empty array given no tests", () =>
+ {
+ const mock_parser = { safeLoad: () => null };
+ const case_ctor = () => null; // unused
+
+ expect( Sut( mock_parser, case_ctor ).loadCases( "" ) )
+ .to.deep.equal( [] );
+ } );
} );