Merge pull request #962 from nasa/csv-export-update-751
[Timeline] Updates to CSV Export
This commit is contained in:
@@ -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,7 +24,8 @@ define(
|
||||
['../../src/actions/ExportTimelineAsCSVAction'],
|
||||
function (ExportTimelineAsCSVAction) {
|
||||
describe("ExportTimelineAsCSVAction", function () {
|
||||
var mockExportService,
|
||||
var mockLog,
|
||||
mockExportService,
|
||||
mockNotificationService,
|
||||
mockNotification,
|
||||
mockDomainObject,
|
||||
@@ -39,6 +40,13 @@ define(
|
||||
['getId', 'getModel', 'getCapability', 'hasCapability']
|
||||
);
|
||||
mockType = jasmine.createSpyObj('type', ['instanceOf']);
|
||||
|
||||
mockLog = jasmine.createSpyObj('$log', [
|
||||
'warn',
|
||||
'error',
|
||||
'info',
|
||||
'debug'
|
||||
]);
|
||||
mockExportService = jasmine.createSpyObj(
|
||||
'exportService',
|
||||
['exportCSV']
|
||||
@@ -63,8 +71,10 @@ define(
|
||||
testContext = { domainObject: mockDomainObject };
|
||||
|
||||
action = new ExportTimelineAsCSVAction(
|
||||
mockLog,
|
||||
mockExportService,
|
||||
mockNotificationService,
|
||||
[],
|
||||
testContext
|
||||
);
|
||||
});
|
||||
@@ -129,8 +139,11 @@ define(
|
||||
});
|
||||
|
||||
describe("and an error occurs", function () {
|
||||
var testError;
|
||||
|
||||
beforeEach(function () {
|
||||
testPromise.reject();
|
||||
testError = { someProperty: "some value" };
|
||||
testPromise.reject(testError);
|
||||
waitsFor(function () {
|
||||
return mockCallback.calls.length > 0;
|
||||
});
|
||||
@@ -145,6 +158,10 @@ define(
|
||||
expect(mockNotificationService.error)
|
||||
.toHaveBeenCalledWith(jasmine.any(String));
|
||||
});
|
||||
|
||||
it("logs the root cause", function () {
|
||||
expect(mockLog.warn).toHaveBeenCalledWith(testError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@ define(
|
||||
|
||||
task = new ExportTimelineAsCSVTask(
|
||||
mockExportService,
|
||||
[],
|
||||
mockDomainObject
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -75,7 +75,7 @@ define(
|
||||
return c === 'metadata' && testMetadata;
|
||||
});
|
||||
|
||||
exporter = new TimelineColumnizer(mockDomainObjects);
|
||||
exporter = new TimelineColumnizer(mockDomainObjects, []);
|
||||
});
|
||||
|
||||
describe("rows", 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 () {
|
||||
|
||||
Reference in New Issue
Block a user