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 { stripInternalProperties } from '../helpers/strip-internal-properties';
import { VersionData } from '../helpers/version-data'; import { VersionData } from '../helpers/version-data';
import type { SidebarStore } from '../store'; import type { SidebarStore } from '../store';
...@@ -22,21 +22,21 @@ export class AnnotationsExporter { ...@@ -22,21 +22,21 @@ export class AnnotationsExporter {
this._store = store; this._store = store;
} }
/** buildExportContent(
* @param now - Test seam annotations: Annotation[],
*/ /* istanbul ignore next - test seam */
buildExportContent(now = new Date()): ExportContent { now = new Date()
): ExportContent {
const profile = this._store.profile(); const profile = this._store.profile();
const annotations = this._store
.allAnnotations()
.map(stripInternalProperties) as APIAnnotationData[];
const versionData = new VersionData(profile, []); const versionData = new VersionData(profile, []);
return { return {
export_date: now.toISOString(), export_date: now.toISOString(),
export_userid: profile.userid ?? '', export_userid: profile.userid ?? '',
client_version: versionData.version, client_version: versionData.version,
annotations, annotations: annotations.map(
stripInternalProperties
) as APIAnnotationData[],
}; };
} }
} }
...@@ -8,7 +8,6 @@ describe('AnnotationsExporter', () => { ...@@ -8,7 +8,6 @@ describe('AnnotationsExporter', () => {
beforeEach(() => { beforeEach(() => {
fakeStore = { fakeStore = {
profile: sinon.stub().returns({ userid: 'userId' }), profile: sinon.stub().returns({ userid: 'userId' }),
allAnnotations: sinon.stub(),
}; };
exporter = new AnnotationsExporter(fakeStore); exporter = new AnnotationsExporter(fakeStore);
}); });
...@@ -27,9 +26,8 @@ describe('AnnotationsExporter', () => { ...@@ -27,9 +26,8 @@ describe('AnnotationsExporter', () => {
$highlight: true, $highlight: true,
}, },
]; ];
fakeStore.allAnnotations.returns(annotations);
const result = exporter.buildExportContent(now); const result = exporter.buildExportContent(annotations, now);
assert.deepEqual(result, { assert.deepEqual(result, {
export_date: now.toISOString(), 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