mirror of
https://github.com/nasa/openmct.git
synced 2024-12-30 18:06:59 +00:00
[Core] Update spec for TypeProvider
Update spec for TypeProvider to handle changes to API for transition of platform/core; WTD-573.
This commit is contained in:
parent
a797ae8a69
commit
9b52843e3f
@ -150,7 +150,7 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Get a specific type by name.
|
* Get a specific type by name.
|
||||||
*
|
*
|
||||||
* @param {string} key the key (machine-readable identifier)
|
* @param {string} [key] the key (machine-readable identifier)
|
||||||
* for the type of interest
|
* for the type of interest
|
||||||
* @returns {Promise<module:core/type/type-impl.TypeImpl>} a
|
* @returns {Promise<module:core/type/type-impl.TypeImpl>} a
|
||||||
* promise for a type object identified by this key.
|
* promise for a type object identified by this key.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
define(
|
define(
|
||||||
['../../src/types/TypeProvider'],
|
['../../src/types/TypeProvider'],
|
||||||
function (typeProviderModule) {
|
function (TypeProvider) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("Type provider", function () {
|
describe("Type provider", function () {
|
||||||
@ -50,162 +50,83 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
captured = {};
|
captured = {};
|
||||||
provider = typeProviderModule.instantiate({
|
provider = new TypeProvider(testTypeDefinitions);
|
||||||
definitions: testTypeDefinitions
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can be instantiated from a factory method", function () {
|
|
||||||
expect(provider).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("looks up non-inherited types by name", function () {
|
it("looks up non-inherited types by name", function () {
|
||||||
provider.getType('basic').then(capture('type'));
|
captured.type = provider.getType('basic');
|
||||||
|
|
||||||
waitsFor(
|
expect(captured.type.getGlyph()).toEqual("X");
|
||||||
function () {
|
expect(captured.type.getName()).toEqual("Basic Type");
|
||||||
return captured.type !== undefined;
|
expect(captured.type.getDescription()).toBeUndefined();
|
||||||
},
|
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getGlyph()).toEqual("X");
|
|
||||||
expect(captured.type.getName()).toEqual("Basic Type");
|
|
||||||
expect(captured.type.getDescription()).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports single inheritance", function () {
|
it("supports single inheritance", function () {
|
||||||
provider.getType('single-subtype').then(capture('type'));
|
captured.type = provider.getType('single-subtype');
|
||||||
|
|
||||||
waitsFor(
|
expect(captured.type.getGlyph()).toEqual("X");
|
||||||
function () {
|
expect(captured.type.getName()).toEqual("Basic Subtype");
|
||||||
return captured.type !== undefined;
|
expect(captured.type.getDescription()).toEqual("A test subtype");
|
||||||
},
|
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getGlyph()).toEqual("X");
|
|
||||||
expect(captured.type.getName()).toEqual("Basic Subtype");
|
|
||||||
expect(captured.type.getDescription()).toEqual("A test subtype");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports multiple inheritance", function () {
|
it("supports multiple inheritance", function () {
|
||||||
provider.getType('multi-subtype').then(capture('type'));
|
captured.type = provider.getType('multi-subtype');
|
||||||
waitsFor(
|
|
||||||
function () {
|
expect(captured.type.getGlyph()).toEqual("Y");
|
||||||
return captured.type !== undefined;
|
expect(captured.type.getName()).toEqual("Multi-parent Subtype");
|
||||||
},
|
expect(captured.type.getDescription()).toEqual("Multi1 Description");
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getGlyph()).toEqual("Y");
|
|
||||||
expect(captured.type.getName()).toEqual("Multi-parent Subtype");
|
|
||||||
expect(captured.type.getDescription()).toEqual("Multi1 Description");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("concatenates capabilities in order", function () {
|
it("concatenates capabilities in order", function () {
|
||||||
provider.getType('multi-subtype').then(capture('type'));
|
captured.type = provider.getType('multi-subtype');
|
||||||
waitsFor(
|
|
||||||
function () {
|
expect(captured.type.getDefinition().capabilities).toEqual(
|
||||||
return captured.type !== undefined;
|
['a1', 'b1', 'a2', 'b2', 'c2', 'a3']
|
||||||
},
|
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
);
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getDefinition().capabilities).toEqual(
|
|
||||||
['a1', 'b1', 'a2', 'b2', 'c2', 'a3']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows lookup of the undefined type", function () {
|
it("allows lookup of the undefined type", function () {
|
||||||
provider.getType(undefined).then(capture('type'));
|
captured.type = provider.getType(undefined);
|
||||||
waitsFor(
|
|
||||||
function () {
|
expect(captured.type.getName()).toEqual("Default");
|
||||||
return captured.type !== undefined;
|
|
||||||
},
|
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getName()).toEqual("Default");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("concatenates capabilities of all undefined types", function () {
|
it("concatenates capabilities of all undefined types", function () {
|
||||||
typeProviderModule.instantiate({
|
captured.type = new TypeProvider(
|
||||||
definitions: testTypeDefinitions.concat([
|
testTypeDefinitions.concat([
|
||||||
{
|
{ capabilities: ['a', 'b', 'c'] },
|
||||||
capabilities: ['a', 'b', 'c']
|
{ capabilities: ['x', 'y', 'z'] }
|
||||||
},
|
|
||||||
{
|
|
||||||
capabilities: ['x', 'y', 'z']
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
}).getType(undefined).then(capture('type'));
|
).getType(undefined);
|
||||||
|
|
||||||
waitsFor(
|
|
||||||
function () {
|
expect(captured.type.getDefinition().capabilities).toEqual(
|
||||||
return captured.type !== undefined;
|
['a', 'b', 'c', 'x', 'y', 'z']
|
||||||
},
|
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
);
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getDefinition().capabilities).toEqual(
|
|
||||||
['a', 'b', 'c', 'x', 'y', 'z']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes capabilities from undefined type in all types", function () {
|
it("includes capabilities from undefined type in all types", function () {
|
||||||
typeProviderModule.instantiate({
|
captured.type = TypeProvider.instantiate(
|
||||||
definitions: testTypeDefinitions.concat([
|
testTypeDefinitions.concat([
|
||||||
{
|
{ capabilities: ['a', 'b', 'c'] },
|
||||||
capabilities: ['a', 'b', 'c']
|
{ capabilities: ['x', 'y', 'z'] }
|
||||||
},
|
|
||||||
{
|
|
||||||
capabilities: ['x', 'y', 'z']
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
}).getType('multi-subtype').then(capture('type'));
|
).getType('multi-subtype');
|
||||||
waitsFor(
|
|
||||||
function () {
|
expect(captured.type.getDefinition().capabilities).toEqual(
|
||||||
return captured.type !== undefined;
|
['a', 'b', 'c', 'x', 'y', 'z', 'a1', 'b1', 'a2', 'b2', 'c2', 'a3']
|
||||||
},
|
|
||||||
"promise resolution",
|
|
||||||
250
|
|
||||||
);
|
);
|
||||||
runs(function () {
|
|
||||||
expect(captured.type.getDefinition().capabilities).toEqual(
|
|
||||||
['a', 'b', 'c', 'x', 'y', 'z', 'a1', 'b1', 'a2', 'b2', 'c2', 'a3']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows types to be listed", function () {
|
it("allows types to be listed", function () {
|
||||||
provider.listTypes().then(capture('types'));
|
captured.types = provider.listTypes();
|
||||||
waitsFor(
|
|
||||||
function () {
|
expect(captured.types.length).toEqual(
|
||||||
return captured.types !== undefined;
|
testTypeDefinitions.filter(function (t) {
|
||||||
},
|
return t.key;
|
||||||
"promise resolution",
|
}).length
|
||||||
250
|
|
||||||
);
|
);
|
||||||
runs(function () {
|
|
||||||
expect(captured.types.length).toEqual(
|
|
||||||
testTypeDefinitions.filter(function (t) {
|
|
||||||
return t.key;
|
|
||||||
}).length
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user