Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitm@lovullo.com>2016-04-28 11:31:42 -0400
committerMike Gerwitz <gerwitm@lovullo.com>2016-04-28 11:31:42 -0400
commite406c198d2a8004fec6d031481e01d862cdda2dd (patch)
tree9ae69781542c4250a5cea6718514d81ddc05149e /test/validate
parent895441850e767c429b62e52ec7d0cfba3207cc9a (diff)
downloadliza-e406c198d2a8004fec6d031481e01d862cdda2dd.tar.gz
liza-e406c198d2a8004fec6d031481e01d862cdda2dd.tar.bz2
liza-e406c198d2a8004fec6d031481e01d862cdda2dd.zip
Add Failure#merge
* src/validate/Failure.js (merge): Added * test/validate/FailureTest.js: Respective tests added
Diffstat (limited to 'test/validate')
-rw-r--r--test/validate/FailureTest.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/validate/FailureTest.js b/test/validate/FailureTest.js
index 9b97e1a..8faa4bc 100644
--- a/test/validate/FailureTest.js
+++ b/test/validate/FailureTest.js
@@ -131,4 +131,44 @@ describe( 'Failure', function()
.to.equal( reason );
} );
} );
+
+
+ describe( '#merge', function()
+ {
+ it( 'rejects non-Failure merges', function()
+ {
+ expect( function()
+ {
+ Sut( DummyField() ).merge( {} );
+ } ).to.throw( TypeError );
+ } );
+
+
+ it( 'merges causes', function()
+ {
+ var cause1 = DummyField(),
+ cause2 = DummyField(),
+ cause3 = DummyField();
+
+ var result = Sut( DummyField(), '', [ cause1 ] )
+ .merge( Sut( DummyField(), '', [ cause2, cause3 ] ) );
+
+ expect( result.getCauses() )
+ .to.deep.equal( [ cause1, cause2, cause3 ] );
+ } );
+
+
+ it( 'merges reasons', function()
+ {
+ var msg1 = 'message 1',
+ msg2 = 'message 2';
+
+ var result = Sut( DummyField(), msg1 )
+ .merge( Sut( DummyField(), msg2 ) )
+ .getReason();
+
+ expect( result ).to.contain( msg1 );
+ expect( result ).to.contain( msg2 );
+ } );
+ } );
} );