Merge remote-tracking branch 'origin/open629'
This commit is contained in:
@@ -24,12 +24,11 @@ define(
|
|||||||
["../../src/actions/CancelAction"],
|
["../../src/actions/CancelAction"],
|
||||||
function (CancelAction) {
|
function (CancelAction) {
|
||||||
|
|
||||||
//TODO: Disabled for NEM Beta
|
describe("The Cancel action", function () {
|
||||||
xdescribe("The Cancel action", function () {
|
var mockDomainObject,
|
||||||
var mockLocation,
|
mockParentObject,
|
||||||
mockDomainObject,
|
capabilities = {},
|
||||||
mockEditorCapability,
|
parentCapabilities = {},
|
||||||
mockUrlService,
|
|
||||||
actionContext,
|
actionContext,
|
||||||
action;
|
action;
|
||||||
|
|
||||||
@@ -42,61 +41,109 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockLocation = jasmine.createSpyObj(
|
|
||||||
"$location",
|
|
||||||
["path"]
|
|
||||||
);
|
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
["getCapability", "hasCapability"]
|
[
|
||||||
|
"getCapability",
|
||||||
|
"hasCapability",
|
||||||
|
"getModel"
|
||||||
|
]
|
||||||
);
|
);
|
||||||
mockEditorCapability = jasmine.createSpyObj(
|
mockDomainObject.getModel.andReturn({});
|
||||||
|
|
||||||
|
mockParentObject = jasmine.createSpyObj(
|
||||||
|
"parentObject",
|
||||||
|
[
|
||||||
|
"getCapability"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
mockParentObject.getCapability.andCallFake(function (name) {
|
||||||
|
return parentCapabilities[name];
|
||||||
|
});
|
||||||
|
|
||||||
|
capabilities.editor = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
["save", "cancel"]
|
["save", "cancel", "isEditContextRoot"]
|
||||||
);
|
);
|
||||||
mockUrlService = jasmine.createSpyObj(
|
capabilities.action = jasmine.createSpyObj(
|
||||||
"urlService",
|
"actionCapability",
|
||||||
["urlForLocation"]
|
[
|
||||||
|
"perform"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
capabilities.location = jasmine.createSpyObj(
|
||||||
|
"locationCapability",
|
||||||
|
[
|
||||||
|
"getOriginal"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
capabilities.location.getOriginal.andReturn(mockPromise(mockDomainObject));
|
||||||
|
capabilities.context = jasmine.createSpyObj(
|
||||||
|
"contextCapability",
|
||||||
|
[
|
||||||
|
"getParent"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
capabilities.context.getParent.andReturn(mockParentObject);
|
||||||
|
|
||||||
|
parentCapabilities.action = jasmine.createSpyObj(
|
||||||
|
"actionCapability",
|
||||||
|
[
|
||||||
|
"perform"
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
actionContext = {
|
actionContext = {
|
||||||
domainObject: mockDomainObject
|
domainObject: mockDomainObject
|
||||||
};
|
};
|
||||||
|
|
||||||
mockDomainObject.hasCapability.andReturn(true);
|
mockDomainObject.getCapability.andCallFake(function (name) {
|
||||||
mockDomainObject.getCapability.andReturn(mockEditorCapability);
|
return capabilities[name];
|
||||||
mockEditorCapability.cancel.andReturn(mockPromise(true));
|
});
|
||||||
|
|
||||||
action = new CancelAction(mockLocation, mockUrlService, actionContext);
|
mockDomainObject.hasCapability.andCallFake(function (name) {
|
||||||
|
return !!capabilities[name];
|
||||||
|
});
|
||||||
|
|
||||||
|
capabilities.editor.cancel.andReturn(mockPromise(true));
|
||||||
|
|
||||||
|
action = new CancelAction(actionContext);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("only applies to domain object with an editor capability", function () {
|
it("only applies to domain object that is being edited", function () {
|
||||||
|
capabilities.editor.isEditContextRoot.andReturn(true);
|
||||||
expect(CancelAction.appliesTo(actionContext)).toBeTruthy();
|
expect(CancelAction.appliesTo(actionContext)).toBeTruthy();
|
||||||
expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor");
|
expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor");
|
||||||
|
|
||||||
|
capabilities.editor.isEditContextRoot.andReturn(false);
|
||||||
|
expect(CancelAction.appliesTo(actionContext)).toBeFalsy();
|
||||||
|
|
||||||
mockDomainObject.hasCapability.andReturn(false);
|
mockDomainObject.hasCapability.andReturn(false);
|
||||||
mockDomainObject.getCapability.andReturn(undefined);
|
|
||||||
expect(CancelAction.appliesTo(actionContext)).toBeFalsy();
|
expect(CancelAction.appliesTo(actionContext)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("invokes the editor capability's save functionality when performed", function () {
|
it("invokes the editor capability's cancel functionality when" +
|
||||||
// Verify precondition
|
" performed", function () {
|
||||||
expect(mockEditorCapability.cancel).not.toHaveBeenCalled();
|
|
||||||
action.perform();
|
action.perform();
|
||||||
|
|
||||||
// Should have called cancel
|
// Should have called cancel
|
||||||
expect(mockEditorCapability.cancel).toHaveBeenCalled();
|
expect(capabilities.editor.cancel).toHaveBeenCalled();
|
||||||
|
|
||||||
// Definitely shouldn't call save!
|
// Definitely shouldn't call save!
|
||||||
expect(mockEditorCapability.save).not.toHaveBeenCalled();
|
expect(capabilities.editor.save).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns to browse when performed", function () {
|
it("navigates to object if existing", function () {
|
||||||
|
mockDomainObject.getModel.andReturn({persisted: 1});
|
||||||
action.perform();
|
action.perform();
|
||||||
expect(mockLocation.path).toHaveBeenCalledWith(
|
expect(capabilities.action.perform).toHaveBeenCalledWith("navigate");
|
||||||
mockUrlService.urlForLocation("browse", mockDomainObject)
|
});
|
||||||
);
|
|
||||||
|
it("navigates to parent if new", function () {
|
||||||
|
mockDomainObject.getModel.andReturn({persisted: undefined});
|
||||||
|
action.perform();
|
||||||
|
expect(parentCapabilities.action.perform).toHaveBeenCalledWith("navigate");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,16 +82,6 @@ define(
|
|||||||
expect(result.a.getModel()).toEqual(model);
|
expect(result.a.getModel()).toEqual(model);
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: Disabled for NEM Beta
|
|
||||||
xit("provides a new, fully constituted domain object for a" +
|
|
||||||
" provided model", function () {
|
|
||||||
var model = { someKey: "some value"},
|
|
||||||
result;
|
|
||||||
result = provider.newObject("a", model);
|
|
||||||
expect(result.getId()).toEqual("a");
|
|
||||||
expect(result.getModel()).toEqual(model);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ define(
|
|||||||
'parent'
|
'parent'
|
||||||
];
|
];
|
||||||
|
|
||||||
xdescribe("ConductorRepresenter", function () {
|
describe("ConductorRepresenter", function () {
|
||||||
var mockThrottle,
|
var mockThrottle,
|
||||||
mockConductorService,
|
mockConductorService,
|
||||||
mockCompile,
|
mockCompile,
|
||||||
|
|||||||
@@ -30,23 +30,21 @@ define(
|
|||||||
var TEST_DOMAIN_VALUE = "some formatted domain value";
|
var TEST_DOMAIN_VALUE = "some formatted domain value";
|
||||||
|
|
||||||
describe("A domain column", function () {
|
describe("A domain column", function () {
|
||||||
var mockDataSet,
|
var mockDatum,
|
||||||
testMetadata,
|
testMetadata,
|
||||||
mockFormatter,
|
mockFormatter,
|
||||||
column;
|
column;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDataSet = jasmine.createSpyObj(
|
|
||||||
"data",
|
|
||||||
["getDomainValue"]
|
|
||||||
);
|
|
||||||
mockFormatter = jasmine.createSpyObj(
|
mockFormatter = jasmine.createSpyObj(
|
||||||
"formatter",
|
"formatter",
|
||||||
["formatDomainValue", "formatRangeValue"]
|
["formatDomainValue", "formatRangeValue"]
|
||||||
);
|
);
|
||||||
testMetadata = {
|
testMetadata = {
|
||||||
key: "testKey",
|
key: "testKey",
|
||||||
name: "Test Name"
|
name: "Test Name",
|
||||||
|
format: "Test Format"
|
||||||
};
|
};
|
||||||
mockFormatter.formatDomainValue.andReturn(TEST_DOMAIN_VALUE);
|
mockFormatter.formatDomainValue.andReturn(TEST_DOMAIN_VALUE);
|
||||||
|
|
||||||
@@ -57,24 +55,24 @@ define(
|
|||||||
expect(column.getTitle()).toEqual("Test Name");
|
expect(column.getTitle()).toEqual("Test Name");
|
||||||
});
|
});
|
||||||
|
|
||||||
xit("looks up data from a data set", function () {
|
describe("when given a datum", function () {
|
||||||
column.getValue(undefined, mockDataSet, 42);
|
beforeEach(function () {
|
||||||
expect(mockDataSet.getDomainValue)
|
mockDatum = {
|
||||||
.toHaveBeenCalledWith(42, "testKey");
|
testKey: "testKeyValue"
|
||||||
});
|
};
|
||||||
|
});
|
||||||
|
|
||||||
xit("formats domain values as time", function () {
|
it("looks up data from the given datum", function () {
|
||||||
mockDataSet.getDomainValue.andReturn(402513731000);
|
expect(column.getValue(undefined, mockDatum))
|
||||||
|
.toEqual({ text: TEST_DOMAIN_VALUE });
|
||||||
|
});
|
||||||
|
|
||||||
// Should have just given the value the formatter gave
|
it("uses formatter to format domain values as requested", function () {
|
||||||
expect(column.getValue(undefined, mockDataSet, 42).text)
|
column.getValue(undefined, mockDatum);
|
||||||
.toEqual(TEST_DOMAIN_VALUE);
|
expect(mockFormatter.formatDomainValue)
|
||||||
|
.toHaveBeenCalledWith("testKeyValue", "Test Format");
|
||||||
|
});
|
||||||
|
|
||||||
// Make sure that service interactions were as expected
|
|
||||||
expect(mockFormatter.formatDomainValue)
|
|
||||||
.toHaveBeenCalledWith(402513731000);
|
|
||||||
expect(mockFormatter.formatRangeValue)
|
|
||||||
.not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ define(
|
|||||||
{
|
{
|
||||||
x: event.pageX - rect.left,
|
x: event.pageX - rect.left,
|
||||||
y: event.pageY - rect.top
|
y: event.pageY - rect.top
|
||||||
},
|
}
|
||||||
domainObject
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ define(
|
|||||||
TEST_ID = "test-id",
|
TEST_ID = "test-id",
|
||||||
DROP_ID = "drop-id";
|
DROP_ID = "drop-id";
|
||||||
|
|
||||||
//TODO: Disabled for NEM Beta
|
describe("The drop gesture", function () {
|
||||||
xdescribe("The drop gesture", function () {
|
|
||||||
var mockDndService,
|
var mockDndService,
|
||||||
mockQ,
|
mockQ,
|
||||||
mockElement,
|
mockElement,
|
||||||
@@ -144,23 +143,6 @@ define(
|
|||||||
expect(mockCompose.perform).toHaveBeenCalled();
|
expect(mockCompose.perform).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("does not invoke compose on drop in browse mode for non-folders", function () {
|
|
||||||
// Set the mockDomainObject to not have the editor capability
|
|
||||||
mockDomainObject.hasCapability.andReturn(false);
|
|
||||||
// Set the mockDomainObject to not have a type of folder
|
|
||||||
mockDomainObject.getModel.andReturn({type: 'notAFolder'});
|
|
||||||
|
|
||||||
callbacks.dragover(mockEvent);
|
|
||||||
expect(mockAction.getActions).toHaveBeenCalledWith({
|
|
||||||
key: 'compose',
|
|
||||||
selectedObject: mockDraggedObject
|
|
||||||
});
|
|
||||||
callbacks.drop(mockEvent);
|
|
||||||
expect(mockCompose.perform).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it("invokes compose on drop in browse mode for folders", function () {
|
it("invokes compose on drop in browse mode for folders", function () {
|
||||||
// Set the mockDomainObject to not have the editor capability
|
// Set the mockDomainObject to not have the editor capability
|
||||||
mockDomainObject.hasCapability.andReturn(false);
|
mockDomainObject.hasCapability.andReturn(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user