mirror of
https://github.com/nasa/openmct.git
synced 2025-01-21 03:55:31 +00:00
[Edit] Add test cases
Add test cases for EditController to account for changes to support warning dialog when unsaved changes are present, WTD-1035.
This commit is contained in:
parent
dc7d504691
commit
0b0753df31
@ -41,17 +41,17 @@ define(
|
||||
);
|
||||
});
|
||||
|
||||
it("places the currently-navigated object in scope", function () {
|
||||
expect(mockScope.navigatedObject).toBeDefined();
|
||||
expect(mockScope.navigatedObject.getId()).toEqual("test");
|
||||
it("exposes the currently-navigated object", function () {
|
||||
expect(controller.navigatedObject()).toBeDefined();
|
||||
expect(controller.navigatedObject().getId()).toEqual("test");
|
||||
});
|
||||
|
||||
it("adds an editor capability to the navigated object", function () {
|
||||
// Should provide an editor capability...
|
||||
expect(mockScope.navigatedObject.getCapability("editor"))
|
||||
expect(controller.navigatedObject().getCapability("editor"))
|
||||
.toBeDefined();
|
||||
// Shouldn't have been the mock capability we provided
|
||||
expect(mockScope.navigatedObject.getCapability("editor"))
|
||||
expect(controller.navigatedObject().getCapability("editor"))
|
||||
.not.toEqual(mockCapability);
|
||||
});
|
||||
|
||||
@ -76,6 +76,23 @@ define(
|
||||
.toHaveBeenCalledWith(navCallback);
|
||||
});
|
||||
|
||||
it("exposes a warning message for unload", function () {
|
||||
var obj = controller.navigatedObject(),
|
||||
mockEditor = jasmine.createSpyObj('editor', ['dirty']);
|
||||
|
||||
// Normally, should be undefined
|
||||
expect(controller.getUnloadWarning()).toBeUndefined();
|
||||
|
||||
// Override the object's editor capability, make it look
|
||||
// like there are unsaved changes.
|
||||
obj.getCapability = jasmine.createSpy();
|
||||
obj.getCapability.andReturn(mockEditor);
|
||||
mockEditor.dirty.andReturn(true);
|
||||
|
||||
// Should have some warning message here now
|
||||
expect(controller.getUnloadWarning()).toEqual(jasmine.any(String));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user