mirror of
https://github.com/nasa/openmct.git
synced 2025-06-06 01:11:41 +00:00
[Persistence] Complete tests for queue
Complete tests for platform/persistence/queue, WTD-1033.
This commit is contained in:
parent
74fecf5271
commit
29584f2a7e
@ -7,6 +7,28 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("The persistence queue", function () {
|
describe("The persistence queue", function () {
|
||||||
|
var mockQ,
|
||||||
|
mockTimeout,
|
||||||
|
mockDialogService,
|
||||||
|
queue;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockQ = jasmine.createSpyObj("$q", ['defer']);
|
||||||
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
|
mockDialogService = jasmine.createSpyObj(
|
||||||
|
'dialogService',
|
||||||
|
['getUserChoice']
|
||||||
|
);
|
||||||
|
queue = new PersistenceQueue(mockQ, mockTimeout, mockDialogService);
|
||||||
|
});
|
||||||
|
|
||||||
|
// PersistenceQueue is just responsible for handling injected
|
||||||
|
// dependencies and wiring the PersistenceQueueImpl and its
|
||||||
|
// handlers. Functionality is tested there, so our test here is
|
||||||
|
// minimal (get back expected interface, no exceptions)
|
||||||
|
it("provides a queue with a put method", function () {
|
||||||
|
expect(queue.put).toEqual(jasmine.any(Function));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,56 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("A queuing persistence capability decorator", function () {
|
describe("A queuing persistence capability decorator", function () {
|
||||||
|
var mockQueue,
|
||||||
|
mockCapabilityService,
|
||||||
|
mockPersistenceConstructor,
|
||||||
|
mockPersistence,
|
||||||
|
mockDomainObject,
|
||||||
|
testModel,
|
||||||
|
decorator;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockQueue = jasmine.createSpyObj('queue', ['put']);
|
||||||
|
mockCapabilityService = jasmine.createSpyObj(
|
||||||
|
'capabilityService',
|
||||||
|
['getCapabilities']
|
||||||
|
);
|
||||||
|
testModel = { someKey: "some value" };
|
||||||
|
mockPersistence = jasmine.createSpyObj(
|
||||||
|
'persistence',
|
||||||
|
['persist', 'refresh']
|
||||||
|
);
|
||||||
|
mockPersistenceConstructor = jasmine.createSpy();
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
'domainObject',
|
||||||
|
['getId']
|
||||||
|
);
|
||||||
|
|
||||||
|
mockCapabilityService.getCapabilities.andReturn({
|
||||||
|
persistence: mockPersistenceConstructor
|
||||||
|
});
|
||||||
|
mockPersistenceConstructor.andReturn(mockPersistence);
|
||||||
|
|
||||||
|
decorator = new QueuingPersistenceCapabilityDecorator(
|
||||||
|
mockQueue,
|
||||||
|
mockCapabilityService
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Here, we verify that the decorator wraps the calls it is expected
|
||||||
|
// to wrap; remaining responsibility belongs to
|
||||||
|
// QueuingPersistenceCapability itself, which has its own tests.
|
||||||
|
|
||||||
|
it("delegates to its wrapped service", function () {
|
||||||
|
decorator.getCapabilities(testModel);
|
||||||
|
expect(mockCapabilityService.getCapabilities)
|
||||||
|
.toHaveBeenCalledWith(testModel);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("wraps its persistence capability's constructor", function () {
|
||||||
|
decorator.getCapabilities(testModel).persistence(mockDomainObject);
|
||||||
|
expect(mockPersistenceConstructor).toHaveBeenCalledWith(mockDomainObject);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user