Commit ffa32aa9 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Expect AnnotationsExporter to receive the annotations list

parent b488fafb
import type { APIAnnotationData } from '../../types/api';
import type { Annotation, APIAnnotationData } from '../../types/api';
import { stripInternalProperties } from '../helpers/strip-internal-properties';
import { VersionData } from '../helpers/version-data';
import type { SidebarStore } from '../store';
......@@ -22,21 +22,21 @@ export class AnnotationsExporter {
this._store = store;
}
/**
* @param now - Test seam
*/
buildExportContent(now = new Date()): ExportContent {
buildExportContent(
annotations: Annotation[],
/* istanbul ignore next - test seam */
now = new Date()
): ExportContent {
const profile = this._store.profile();
const annotations = this._store
.allAnnotations()
.map(stripInternalProperties) as APIAnnotationData[];
const versionData = new VersionData(profile, []);
return {
export_date: now.toISOString(),
export_userid: profile.userid ?? '',
client_version: versionData.version,
annotations,
annotations: annotations.map(
stripInternalProperties
) as APIAnnotationData[],
};
}
}
......@@ -8,7 +8,6 @@ describe('AnnotationsExporter', () => {
beforeEach(() => {
fakeStore = {
profile: sinon.stub().returns({ userid: 'userId' }),
allAnnotations: sinon.stub(),
};
exporter = new AnnotationsExporter(fakeStore);
});
......@@ -27,9 +26,8 @@ describe('AnnotationsExporter', () => {
$highlight: true,
},
];
fakeStore.allAnnotations.returns(annotations);
const result = exporter.buildExportContent(now);
const result = exporter.buildExportContent(annotations, now);
assert.deepEqual(result, {
export_date: now.toISOString(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment