[Forms] Edit Properties specs
Add baseline specs (not yet matched up to current implementation) for Edit Properties action. WTD-593.
This commit is contained in:
67
platform/commonUI/edit/test/actions/PropertiesActionSpec.js
Normal file
67
platform/commonUI/edit/test/actions/PropertiesActionSpec.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*global define,describe,it,xit,expect,beforeEach*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
['../../src/actions/PropertiesAction'],
|
||||||
|
function (PropertiesAction) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
describe("Properties action", function () {
|
||||||
|
var captured, model, object, context, input, dialogService, action;
|
||||||
|
|
||||||
|
function capture(k) { return function (v) { captured[k] = v; }; }
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
var capabilities = {
|
||||||
|
type: { getProperties: function () { return []; } },
|
||||||
|
persistence: {
|
||||||
|
persist: function () {
|
||||||
|
captured.persisted = true;
|
||||||
|
return promises.as(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mutation: {
|
||||||
|
mutate: function (c) {
|
||||||
|
captured.mutated = true;
|
||||||
|
return promises.as(c(model));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
model = {};
|
||||||
|
input = {};
|
||||||
|
object = {
|
||||||
|
getId: function () { return 'test-id'; },
|
||||||
|
getCapability: function (k) {
|
||||||
|
return promises.as(capabilities[k]);
|
||||||
|
},
|
||||||
|
getModel: function () { return model; }
|
||||||
|
};
|
||||||
|
context = { someKey: "some value "};
|
||||||
|
dialogService = {
|
||||||
|
getUserInput: function () {
|
||||||
|
return promises.as(input);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
captured = {};
|
||||||
|
action = new PropertiesAction(object, context, dialogService);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("provides action metadata", function () {
|
||||||
|
var metadata = action.metadata();
|
||||||
|
expect(metadata.context).toEqual(context);
|
||||||
|
expect(metadata.category).toEqual('contextual');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("persists when an action is performed", function () {
|
||||||
|
action.perform();
|
||||||
|
expect(captured.persisted).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not persist any changes upon cancel", function () {
|
||||||
|
input = undefined;
|
||||||
|
action.perform();
|
||||||
|
expect(captured.persisted).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
51
platform/commonUI/edit/test/actions/PropertiesDialogSpec.js
Normal file
51
platform/commonUI/edit/test/actions/PropertiesDialogSpec.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*global define,describe,it,xit,expect,beforeEach*/
|
||||||
|
|
||||||
|
define(
|
||||||
|
["../../src/actions/PropertiesDialog"],
|
||||||
|
function (PropertiesDialog) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
describe("Properties dialog", function () {
|
||||||
|
|
||||||
|
var type, properties, domainObject, model, dialog;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
type = {
|
||||||
|
getProperties: function () { return properties; }
|
||||||
|
};
|
||||||
|
domainObject = {
|
||||||
|
getModel: function () { return model; }
|
||||||
|
};
|
||||||
|
model = { x: "initial value" };
|
||||||
|
|
||||||
|
dialog = new PropertiesDialog(type, domainObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides sections based on type properties", function () {
|
||||||
|
expect(
|
||||||
|
dialog.getSections()[0].rows.length
|
||||||
|
).toEqual(properties.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("pulls initial values from object model", function () {
|
||||||
|
expect(
|
||||||
|
dialog.getSections()[0].rows[0].value
|
||||||
|
).toEqual("initial value");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("populates models with form results", function () {
|
||||||
|
dialog.updateModel(model, {
|
||||||
|
a: "new value",
|
||||||
|
b: "other new value",
|
||||||
|
c: 42
|
||||||
|
});
|
||||||
|
expect(model).toEqual({
|
||||||
|
x: "new value",
|
||||||
|
y: "other new value",
|
||||||
|
z: 42
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
"EditController",
|
"EditController",
|
||||||
"actions/CancelAction",
|
"actions/CancelAction",
|
||||||
"actions/EditAction",
|
"actions/EditAction",
|
||||||
|
"actions/PropertiesAction",
|
||||||
|
"actions/PropertiesDialog",
|
||||||
"actions/RemoveAction",
|
"actions/RemoveAction",
|
||||||
"actions/SaveAction",
|
"actions/SaveAction",
|
||||||
"capabilities/EditableContextCapability",
|
"capabilities/EditableContextCapability",
|
||||||
|
|||||||
Reference in New Issue
Block a user