Files
openmct/platform/core/test/capabilities/ContextualDomainObjectSpec.js
Victor Woeltjen 2b82262775 [Core] Add specs for contextual objects
Add specs for the context capability, and the domain object
wrapper which introduces it. Ongoing transition work for
platform/core, WTD-573.
2014-11-21 16:22:16 -08:00

63 lines
2.0 KiB
JavaScript

/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/**
* ContextualDomainObjectSpec. Created by vwoeltje on 11/6/14.
*/
define(
["../../src/capabilities/ContextualDomainObject"],
function (ContextualDomainObject) {
"use strict";
var DOMAIN_OBJECT_METHODS = [
"getId",
"getModel",
"getCapability",
"hasCapability",
"useCapability"
];
describe("A contextual domain object", function () {
var mockParent,
mockDomainObject,
model,
contextualDomainObject;
beforeEach(function () {
mockParent = jasmine.createSpyObj("parent", DOMAIN_OBJECT_METHODS);
mockDomainObject = jasmine.createSpyObj("parent", DOMAIN_OBJECT_METHODS);
model = { someKey: "some value" };
mockDomainObject.getCapability.andReturn("some capability");
mockDomainObject.getModel.andReturn(model);
contextualDomainObject = new ContextualDomainObject(
mockDomainObject,
mockParent
);
});
it("adds a context capability to a domain object", function () {
var context = contextualDomainObject.getCapability('context');
// Expect something that looks like a context capability
expect(context).toBeDefined();
expect(context.getPath).toBeDefined();
expect(context.getRoot).toBeDefined();
expect(context.getParent()).toEqual(mockParent);
});
it("does not shadow other domain object methods", function () {
expect(contextualDomainObject.getModel())
.toEqual(model);
expect(contextualDomainObject.getCapability("other"))
.toEqual("some capability");
});
});
}
);