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