[Status] Revise API

Change method names, add a getter to status capability;
per code review feedback, nasa/openmctweb#319.
This commit is contained in:
Victor Woeltjen
2015-11-20 09:46:08 -08:00
parent b5d1118a3f
commit 400b992ec3
6 changed files with 27 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ define(
mockStatusService = jasmine.createSpyObj(
'statusService',
[ 'listen', 'setStatus', 'getStatus' ]
[ 'listen', 'setStatus', 'listStatuses' ]
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
@@ -49,7 +49,7 @@ define(
mockUnlisten = jasmine.createSpy('unlisten');
mockStatusService.listen.andReturn(mockUnlisten);
mockStatusService.getStatus.andReturn(testStatusFlags);
mockStatusService.listStatuses.andReturn(testStatusFlags);
mockDomainObject.getId.andReturn(testId);
capability = new StatusCapability(
@@ -69,7 +69,7 @@ define(
});
it("gets status from the statusService", function () {
expect(capability.get()).toBe(testStatusFlags);
expect(capability.list()).toBe(testStatusFlags);
});
it("listens to changes from the statusService", function () {
@@ -79,6 +79,11 @@ define(
expect(mockStatusService.listen)
.toHaveBeenCalledWith(testId, mockCallback);
});
it("allows statuses to be checked individually", function () {
expect(capability.get('some-unset-status')).toBe(false);
expect(capability.get(testStatusFlags[0])).toBe(true);
});
});
}
);

View File

@@ -66,7 +66,7 @@ define(
);
mockStatusCapability = jasmine.createSpyObj(
'status',
[ 'get', 'set', 'listen' ]
[ 'list', 'get', 'set', 'listen' ]
);
mockUnlisten = jasmine.createSpy();
@@ -79,7 +79,7 @@ define(
delete elementClasses[c];
});
mockStatusCapability.get.andReturn(testStatusFlags);
mockStatusCapability.list.andReturn(testStatusFlags);
mockStatusCapability.listen.andReturn(mockUnlisten);
mockDomainObject.getCapability.andCallFake(function (c) {

View File

@@ -54,14 +54,14 @@ define(
});
it("initially contains no flags for an object", function () {
expect(statusService.getStatus(testId)).toEqual([]);
expect(statusService.listStatuses(testId)).toEqual([]);
});
it("stores and clears status flags", function () {
statusService.setStatus(testId, testStatus, true);
expect(statusService.getStatus(testId)).toEqual([testStatus]);
expect(statusService.listStatuses(testId)).toEqual([testStatus]);
statusService.setStatus(testId, testStatus, false);
expect(statusService.getStatus(testId)).toEqual([]);
expect(statusService.listStatuses(testId)).toEqual([]);
});
it("uses topic to listen for changes", function () {