[Core] Update failing specs

Update failing specs in core after changes for WTD-1033.
This commit is contained in:
Victor Woeltjen
2015-03-24 16:26:05 -07:00
parent c55f9ff092
commit 5867f8ad98
2 changed files with 24 additions and 2 deletions

View File

@@ -10,12 +10,15 @@ define(
describe("The mutation capability", function () { describe("The mutation capability", function () {
var testModel, var testModel,
mockNow,
domainObject = { getModel: function () { return testModel; } }, domainObject = { getModel: function () { return testModel; } },
mutation; mutation;
beforeEach(function () { beforeEach(function () {
testModel = { number: 6 }; testModel = { number: 6 };
mutation = new MutationCapability(domainObject); mockNow = jasmine.createSpy('now');
mockNow.andReturn(12321);
mutation = new MutationCapability(mockNow, domainObject);
}); });
it("allows mutation of a model", function () { it("allows mutation of a model", function () {
@@ -41,6 +44,24 @@ define(
// Number should not have been changed // Number should not have been changed
expect(testModel.number).toEqual(6); expect(testModel.number).toEqual(6);
}); });
it("attaches a timestamp on mutation", function () {
// Verify precondition
expect(testModel.modified).toBeUndefined();
mutation.invoke(function (m) {
m.number = m.number * 7;
});
// Should have gotten a timestamp from 'now'
expect(testModel.modified).toEqual(12321);
});
it("allows a timestamp to be provided", function () {
mutation.invoke(function (m) {
m.number = m.number * 7;
}, 42);
// Should have gotten a timestamp from 'now'
expect(testModel.modified).toEqual(42);
});
}); });
} }
); );

View File

@@ -23,7 +23,8 @@ define(
); );
mockDomainObject = { mockDomainObject = {
getId: function () { return id; }, getId: function () { return id; },
getModel: function () { return model; } getModel: function () { return model; },
useCapability: jasmine.createSpy()
}; };
persistence = new PersistenceCapability( persistence = new PersistenceCapability(
mockPersistenceService, mockPersistenceService,