[Context] Add test, tweak logic
Add test to verify that warnings are not shown based on composition/location inconsistencies when editing.
This commit is contained in:
@@ -68,7 +68,7 @@ define(
|
|||||||
// Don't validate while editing; consistency is not
|
// Don't validate while editing; consistency is not
|
||||||
// necessarily expected due to unsaved changes.
|
// necessarily expected due to unsaved changes.
|
||||||
var editor = domainObject.getCapability('editor');
|
var editor = domainObject.getCapability('editor');
|
||||||
if (editor && !editor.inEditContext()) {
|
if (!editor || !editor.inEditContext()) {
|
||||||
validate(domainObject.getId(), parentObject);
|
validate(domainObject.getId(), parentObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ define(
|
|||||||
var mockLog,
|
var mockLog,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockParentObject,
|
mockParentObject,
|
||||||
|
mockEditor,
|
||||||
testParentModel,
|
testParentModel,
|
||||||
contextualize;
|
contextualize;
|
||||||
|
|
||||||
@@ -52,11 +53,19 @@ define(
|
|||||||
mockParentObject =
|
mockParentObject =
|
||||||
jasmine.createSpyObj('parentObject', DOMAIN_OBJECT_METHODS);
|
jasmine.createSpyObj('parentObject', DOMAIN_OBJECT_METHODS);
|
||||||
|
|
||||||
|
mockEditor =
|
||||||
|
jasmine.createSpyObj('editor', ['inEditContext']);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn("abc");
|
mockDomainObject.getId.andReturn("abc");
|
||||||
mockDomainObject.getModel.andReturn({});
|
mockDomainObject.getModel.andReturn({});
|
||||||
mockParentObject.getId.andReturn("parent");
|
mockParentObject.getId.andReturn("parent");
|
||||||
mockParentObject.getModel.andReturn(testParentModel);
|
mockParentObject.getModel.andReturn(testParentModel);
|
||||||
|
|
||||||
|
mockEditor.inEditContext.andReturn(false);
|
||||||
|
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||||
|
return c === 'editor' && mockEditor;
|
||||||
|
});
|
||||||
|
|
||||||
contextualize = new Contextualize(mockLog);
|
contextualize = new Contextualize(mockLog);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,6 +91,12 @@ define(
|
|||||||
expect(mockLog.warn).toHaveBeenCalled();
|
expect(mockLog.warn).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not issue warnings for objects being edited", function () {
|
||||||
|
mockEditor.inEditContext.andReturn(true);
|
||||||
|
testParentModel.composition = ["xyz"];
|
||||||
|
contextualize(mockDomainObject, mockParentObject);
|
||||||
|
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user