Breeze issue with complexType change tracking -
i use angular , breeze in app , use "haschangeschanged" event handling state of entities stored in entitymanager. have problem when have entity property complextype , isscalar=false. problem occurs when make request twice (without changing entity) , same entity. on second request "haschangeschanged" event fired haschanges=true. in moment when event fired entity has state "modified", after data loaded state changed "unchanged".
i've wrote (jasmine) unit test. in comments information assertion throws error.
var entity, haschanges = false, listeners = { onchange: function (event) { console.log('change', event.haschanges); } }; spyon(listeners, 'onchange'); $httpbackend.expectget('json/sampleentity?').respond(200, [ { id: 1, name: 'some name', data: {}, $type: 'sampleentity', elements: [ { etype: 'el1' } ] } ]); manager.haschangeschanged.subscribe(function (event) { haschanges = event.haschanges; }); var query = new breeze.entityquery('sampleentity'); manager.executequery(query).then(function (data) { entity = data.results[0]; }); $httpbackend.flush(); expect(haschanges).tobe(false); // ok expect(entity.entityaspect.entitystate.isunchanged()).tobe(true); // ok $httpbackend.expectget('json/sampleentity?').respond(200, [ { id: 1, name: 'some name', data: {}, $type: 'sampleentity', elements: [ { etype: 'el1' } ] } ]); manager.executequery(query).then(function (data) { entity = data.results[0]; }); $httpbackend.flush(); expect(haschanges).tobe(false); // error expect(entity.entityaspect.entitystate.isunchanged()).tobe(true); // ok
is expected behavior? , if not how can fix it?
Comments
Post a Comment