[Timeline] Test inclusion of metadata headers

This commit is contained in:
Victor Woeltjen 2016-03-08 10:27:50 -08:00
parent fd92c5f970
commit 0c2285719e

View File

@ -26,6 +26,7 @@ define(
function (TimelineCSVExporter) {
describe("TimelineCSVExporter", function () {
var mockDomainObjects,
testMetadata,
exporter;
function makeMockDomainObject(model, index) {
@ -41,16 +42,28 @@ define(
);
mockDomainObject.getId.andReturn('id-' + index);
mockDomainObject.getModel.andReturn(model);
mockDomainObject.useCapability.andCallFake(function (c) {
return c === 'metadata' && [];
});
return mockDomainObject;
}
beforeEach(function () {
testMetadata = [
{ name: "abc", value: 123 },
{ name: "xyz", value: 456 }
];
mockDomainObjects = [
{ composition: [ 'a', 'b', 'c' ] },
{ relationships: { modes: [ 'x', 'y' ] } },
{ }
].map(makeMockDomainObject);
mockDomainObjects[2].useCapability.andCallFake(function (c) {
return c === 'metadata' && testMetadata;
});
exporter = new TimelineCSVExporter(mockDomainObjects);
});
@ -79,7 +92,20 @@ define(
});
});
describe("headers", function () {
var headers;
beforeEach(function () {
headers = exporter.headers();
});
it("contains all metadata properties", function () {
testMetadata.forEach(function (property) {
expect(headers.indexOf(property.name))
.not.toEqual(-1);
});
});
});
});
}