Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2017-01-29 23:21:14 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2017-01-30 00:29:25 -0500
commit28d74d70685e0824b5895979d7603587c87b651b (patch)
treefa5cd8f3a305d98fa20a7ba9812f51ef91278007
parent24180e704aaec8b1610a24d1f76ba66e70e97b02 (diff)
downloadliza-28d74d70685e0824b5895979d7603587c87b651b.tar.gz
liza-28d74d70685e0824b5895979d7603587c87b651b.tar.bz2
liza-28d74d70685e0824b5895979d7603587c87b651b.zip
ValidStateMonitor: handle empty diff on past failure
See the description in the test case. This is a bug fix. * src/validate/ValidStateMonitor.js (_checkCauseFix): Do not consider an empty diff on a past failure to be a fix. * test/validate/ValidStateMonitorTest.js: Add test. DEV-2296
-rw-r--r--src/validate/ValidStateMonitor.js5
-rw-r--r--test/validate/ValidStateMonitorTest.js19
2 files changed, 21 insertions, 3 deletions
diff --git a/src/validate/ValidStateMonitor.js b/src/validate/ValidStateMonitor.js
index 59d4b66..9fb6ef5 100644
--- a/src/validate/ValidStateMonitor.js
+++ b/src/validate/ValidStateMonitor.js
@@ -298,9 +298,8 @@ module.exports = Class( 'ValidStateMonitor' )
// and there must be data for this index for the field
// in question (if the field wasn't touched, then of
// course there's no failure!)
- if ( ( fail === undefined )
- || ( !( fail[ cause_index ] )
- && ( field[ cause_index ] !== undefined ) )
+ if ( ( ( fail === undefined ) || !( fail[ cause_index ] ) )
+ && ( field[ cause_index ] !== undefined )
)
{
found( field[ cause_index ] );
diff --git a/test/validate/ValidStateMonitorTest.js b/test/validate/ValidStateMonitorTest.js
index 75dab73..52dc272 100644
--- a/test/validate/ValidStateMonitorTest.js
+++ b/test/validate/ValidStateMonitorTest.js
@@ -318,6 +318,25 @@ describe( 'ValidStateMonitor', function()
} );
+ // if a diff is present for a previously failed key (e.g. foo),
+ // but contains no changes (e.g. [ undefined ]), and doesn't
+ // include the failure on the second call, then it should not be
+ // considered to be a fix (this is a bugfix)
+ it( 'keeps past failures on key if failure does not reoccur', () =>
+ {
+ const fail_past = mkfail( 'foo', [ 'bar', 'baz' ] );
+
+ return mkstore( { foo: [ undefined, undefined ] } )
+ .then( data =>
+ Sut()
+ .update( data, { foo: fail_past } )
+ // no failure or fix (foo has no updates)
+ .then( sut => sut.update( data, {} ) )
+ .then( sut => expect( sut.hasFailures() ).to.be.true )
+ );
+ } );
+
+
it( 'does not trigger failure event for existing', function()
{
var called = 0;