[Forms] Complete specs
Fill in new specs and amend existing specs to ensure full coverage after integration of forms component, and associated changes. WTD-593.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*global define,describe,it,xit,expect,beforeEach*/
|
||||
/*global define,describe,it,xit,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
['../../src/actions/PropertiesAction'],
|
||||
@@ -6,9 +6,7 @@ define(
|
||||
"use strict";
|
||||
|
||||
describe("Properties action", function () {
|
||||
var captured, model, object, context, input, dialogService, action;
|
||||
|
||||
function capture(k) { return function (v) { captured[k] = v; }; }
|
||||
var capabilities, model, object, context, input, dialogService, action;
|
||||
|
||||
function mockPromise(value) {
|
||||
return {
|
||||
@@ -19,17 +17,19 @@ define(
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
var capabilities = {
|
||||
capabilities = {
|
||||
type: { getProperties: function () { return []; } },
|
||||
persistence: {},
|
||||
mutation: {}
|
||||
persistence: jasmine.createSpyObj("persistence", ["persist"]),
|
||||
mutation: jasmine.createSpy("mutation")
|
||||
};
|
||||
model = {};
|
||||
input = {};
|
||||
object = {
|
||||
getId: function () { return 'test-id'; },
|
||||
getCapability: function (k) { return capabilities[k]; },
|
||||
getModel: function () { return model; }
|
||||
getModel: function () { return model; },
|
||||
useCapability: function (k, v) { return capabilities[k](v); },
|
||||
hasCapability: function () { return true; }
|
||||
};
|
||||
context = { someKey: "some value", domainObject: object };
|
||||
dialogService = {
|
||||
@@ -37,18 +37,34 @@ define(
|
||||
return mockPromise(input);
|
||||
}
|
||||
};
|
||||
captured = {};
|
||||
action = new PropertiesAction(object, context, dialogService);
|
||||
|
||||
capabilities.mutation.andReturn(true);
|
||||
|
||||
action = new PropertiesAction(dialogService, context);
|
||||
});
|
||||
|
||||
it("persists when an action is performed", function () {
|
||||
|
||||
action.perform();
|
||||
expect(capabilities.persistence.persist)
|
||||
.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not persist any changes upon cancel", function () {
|
||||
// input = undefined;
|
||||
// action.perform();
|
||||
// expect(captured.persisted).toBeFalsy();
|
||||
input = undefined;
|
||||
action.perform();
|
||||
expect(capabilities.persistence.persist)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("mutates an object when performed", function () {
|
||||
action.perform();
|
||||
expect(capabilities.mutation).toHaveBeenCalled();
|
||||
capabilities.mutation.mostRecentCall.args[0]({});
|
||||
});
|
||||
|
||||
it("is only applicable when a domain object is in context", function () {
|
||||
expect(PropertiesAction.appliesTo(context)).toBeTruthy();
|
||||
expect(PropertiesAction.appliesTo({})).toBeFalsy();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user