mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 07:00:49 +00:00
[Timeline] Update specs for indexes instead of ids
This commit is contained in:
parent
ba0d9a186b
commit
73b922facf
@ -23,13 +23,20 @@
|
||||
define(
|
||||
['../../src/actions/CompositionColumn'],
|
||||
function (CompositionColumn) {
|
||||
var TEST_IDS = ['a', 'b', 'c', 'd', 'e', 'f'];
|
||||
|
||||
describe("CompositionColumn", function () {
|
||||
var testIndex,
|
||||
testIdMap,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
testIndex = 3;
|
||||
column = new CompositionColumn(testIndex);
|
||||
testIdMap = TEST_IDS.reduce(function (map, id, index) {
|
||||
map[id] = index;
|
||||
return map;
|
||||
}, {});
|
||||
column = new CompositionColumn(testIndex, testIdMap);
|
||||
});
|
||||
|
||||
it("includes a one-based index in its name", function () {
|
||||
@ -46,15 +53,13 @@ define(
|
||||
'domainObject',
|
||||
['getId', 'getModel', 'getCapability']
|
||||
);
|
||||
testModel = {
|
||||
composition: ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
};
|
||||
testModel = { composition: TEST_IDS };
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
});
|
||||
|
||||
it("returns a corresponding identifier", function () {
|
||||
it("returns a corresponding value from the map", function () {
|
||||
expect(column.value(mockDomainObject))
|
||||
.toEqual(testModel.composition[testIndex]);
|
||||
.toEqual(testIdMap[testModel.composition[testIndex]]);
|
||||
});
|
||||
|
||||
it("returns nothing when composition is exceeded", function () {
|
||||
|
@ -24,10 +24,12 @@ define(
|
||||
['../../src/actions/IdColumn'],
|
||||
function (IdColumn) {
|
||||
describe("IdColumn", function () {
|
||||
var column;
|
||||
var testIdMap,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
column = new IdColumn();
|
||||
testIdMap = { "foo": "bar" };
|
||||
column = new IdColumn(testIdMap);
|
||||
});
|
||||
|
||||
it("has a name", function () {
|
||||
@ -47,9 +49,9 @@ define(
|
||||
mockDomainObject.getId.andReturn(testId);
|
||||
});
|
||||
|
||||
it("provides a domain object's identifier", function () {
|
||||
it("provides a value mapped from domain object's identifier", function () {
|
||||
expect(column.value(mockDomainObject))
|
||||
.toEqual(testId);
|
||||
.toEqual(testIdMap[testId]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -23,13 +23,20 @@
|
||||
define(
|
||||
['../../src/actions/ModeColumn'],
|
||||
function (ModeColumn) {
|
||||
var TEST_IDS = ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
|
||||
describe("ModeColumn", function () {
|
||||
var testIndex,
|
||||
testIdMap,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
testIndex = 3;
|
||||
column = new ModeColumn(testIndex);
|
||||
testIdMap = TEST_IDS.reduce(function (map, id, index) {
|
||||
map[id] = index;
|
||||
return map;
|
||||
}, {});
|
||||
column = new ModeColumn(testIndex, testIdMap);
|
||||
});
|
||||
|
||||
it("includes a one-based index in its name", function () {
|
||||
@ -48,15 +55,15 @@ define(
|
||||
);
|
||||
testModel = {
|
||||
relationships: {
|
||||
modes: ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
modes: TEST_IDS
|
||||
}
|
||||
};
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
});
|
||||
|
||||
it("returns a corresponding identifier", function () {
|
||||
it("returns a corresponding value from the map", function () {
|
||||
expect(column.value(mockDomainObject))
|
||||
.toEqual(testModel.relationships.modes[testIndex]);
|
||||
.toEqual(testIdMap[testModel.relationships.modes[testIndex]]);
|
||||
});
|
||||
|
||||
it("returns nothing when relationships are exceeded", function () {
|
||||
|
@ -94,13 +94,6 @@ define(
|
||||
it("include one row per domain object", function () {
|
||||
expect(rows.length).toEqual(mockDomainObjects.length);
|
||||
});
|
||||
|
||||
it("includes identifiers for each domain object", function () {
|
||||
rows.forEach(function (row, index) {
|
||||
var id = mockDomainObjects[index].getId();
|
||||
expect(row.indexOf(id)).not.toEqual(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("headers", function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user