Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-03-06 11:41:21 -0500
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-03-06 11:41:21 -0500
commit0d169ea9ebc35653805228e8af3cc3966ac93e05 (patch)
treec8064f64ad3ff73fed0fdc657b8e65411d415eb6 /progtest
parent0cb43d5e8a044db73bb13698137c444c05b8fd47 (diff)
downloadtame-0d169ea9ebc35653805228e8af3cc3966ac93e05.tar.gz
tame-0d169ea9ebc35653805228e8af3cc3966ac93e05.tar.bz2
tame-0d169ea9ebc35653805228e8af3cc3966ac93e05.zip
progtest: Return empty array of test cases if none providedv2.11.1
* progtest/src/reader/YamlTestReader.js (loadCases): Handle absence of any test cases. * progtest/test/reader/YamlTestReaderTest.js: New respective test.
Diffstat (limited to 'progtest')
-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( [] );
+ } );
} );