mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 16:10:23 +00:00
[Common UI] Continue filling in Browse specs
Continue filling in specs for scripts introduced as part of bundle platform/commonUI/browse, which is responsible for browse mode. WTD-574.
This commit is contained in:
@ -8,7 +8,89 @@ define(
|
||||
function (CreateWizard) {
|
||||
"use strict";
|
||||
|
||||
describe("The create action provider", function () {
|
||||
describe("The create wizard", function () {
|
||||
var mockType,
|
||||
mockParent,
|
||||
mockProperties,
|
||||
wizard;
|
||||
|
||||
function createMockProperty(name) {
|
||||
var mockProperty = jasmine.createSpyObj(
|
||||
"property" + name,
|
||||
[ "getDefinition", "getValue", "setValue" ]
|
||||
);
|
||||
mockProperty.getDefinition.andReturn({
|
||||
name: name,
|
||||
key: name.toLowerCase()
|
||||
});
|
||||
return mockProperty;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockType = jasmine.createSpyObj(
|
||||
"type",
|
||||
[
|
||||
"getKey",
|
||||
"getGlyph",
|
||||
"getName",
|
||||
"getDescription",
|
||||
"getProperties",
|
||||
"getInitialModel"
|
||||
]
|
||||
);
|
||||
mockParent = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
[
|
||||
"getId",
|
||||
"getModel",
|
||||
"getCapability"
|
||||
]
|
||||
);
|
||||
mockProperties = [ "A", "B", "C" ].map(createMockProperty);
|
||||
|
||||
mockType.getKey.andReturn("test");
|
||||
mockType.getGlyph.andReturn("T");
|
||||
mockType.getDescription.andReturn("a test type");
|
||||
mockType.getName.andReturn("Test");
|
||||
mockType.getInitialModel.andReturn({});
|
||||
mockType.getProperties.andReturn(mockProperties);
|
||||
|
||||
wizard = new CreateWizard(
|
||||
mockType,
|
||||
mockParent
|
||||
);
|
||||
});
|
||||
|
||||
it("creates a form model with a Properties section", function () {
|
||||
expect(wizard.getFormModel().sections[0].name)
|
||||
.toEqual("Properties");
|
||||
});
|
||||
|
||||
it("adds one row per defined type property", function () {
|
||||
// Three properties were defined in the mock type
|
||||
expect(wizard.getFormModel().sections[0].rows.length)
|
||||
.toEqual(3);
|
||||
});
|
||||
|
||||
it("interprets form data using type-defined properties", function () {
|
||||
// Use key names from mock properties
|
||||
wizard.createModel({
|
||||
a: "field 0",
|
||||
b: "field 1",
|
||||
c: "field 2"
|
||||
});
|
||||
|
||||
// Should have gotten a setValue call
|
||||
mockProperties.forEach(function (mockProperty, i) {
|
||||
expect(mockProperty.setValue).toHaveBeenCalledWith(
|
||||
{ type: 'test' },
|
||||
"field " + i
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user