Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2017-02-16 16:02:19 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2017-02-16 16:03:35 -0500
commit73390530bff0f0d70bd5ad67be91b0cff279a24d (patch)
treeb2f3bca89a7f7cf5a724a9bc05b08dd278b0955a
parent71024bd389205492c88263ef0b8d126fca14ef67 (diff)
downloadliza-73390530bff0f0d70bd5ad67be91b0cff279a24d.tar.gz
liza-73390530bff0f0d70bd5ad67be91b0cff279a24d.tar.bz2
liza-73390530bff0f0d70bd5ad67be91b0cff279a24d.zip
Add missing #updateFailures test
Not sure how this was missing...! * test/validate/DataValidatorTest.js: Add test.
-rw-r--r--test/validate/DataValidatorTest.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/validate/DataValidatorTest.js b/test/validate/DataValidatorTest.js
index 272aab0..e2f1b3f 100644
--- a/test/validate/DataValidatorTest.js
+++ b/test/validate/DataValidatorTest.js
@@ -319,6 +319,58 @@ describe( 'DataValidator', () =>
} );
+ describe( '#updateFailures', () =>
+ {
+ it( 'directly updates failures', () =>
+ {
+ const bvalidator = createMockBucketValidator();
+ const vmonitor = ValidStateMonitor();
+ const dep_factory = createMockDependencyFactory();
+
+ const getStore = createStubStore();
+ const { bstore } = getStore();
+
+ const diff = {
+ foo: [ 'bar' ],
+ bar: [ 'baz' ],
+ };
+
+ const failures = {};
+
+ const mock_vmonitor = sinon.mock( vmonitor );
+ const mock_bstore = sinon.mock( bstore );
+
+ // clears previous diffs
+ mock_bstore.expects( 'clear' )
+ .once()
+ .returns( Promise.resolve( bstore) );
+
+ mock_vmonitor
+ .expects( 'update' )
+ .once()
+ .withExactArgs( getStore().store, failures );
+
+ return Sut( bvalidator, vmonitor, dep_factory, getStore )
+ .updateFailures( diff, failures )
+ .then( () =>
+ {
+ mock_vmonitor.verify();
+ mock_bstore.verify();
+
+ // keep in mind that we are using MemoryStore for this
+ // test (whereas a real implementation would probably be
+ // using a DiffStore)
+ return Promise.all(
+ Object.keys( diff ).map( key =>
+ expect( bstore.get( key ) )
+ .to.eventually.deep.equal( diff[ key ] )
+ )
+ );
+ } );
+ } );
+ } );
+
+
describe( '#clearFailures', () =>
{
it( 'proxies to validator', () =>