1
0
Fork 0

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
master
Mike Gerwitz 2017-01-29 23:21:14 -05:00
parent 24180e704a
commit 28d74d7068
2 changed files with 21 additions and 3 deletions

View File

@ -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 ] );

View File

@ -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;