Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions feature-utils/poly-import/utils/zipfile-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ export class ZipFileEntryMock {
}

export class ZipFileMock {
constructor() {
constructor(
dataFilePairs = [["foo.json", { foo: "bar" }]],
name = "facebook-facebookuser.zip"
) {
this.id = "polypod://de71f571-d90a-45e0-b007-d8f059e0541b";
this.time = new Date("2021-09-20T16:37:36.243Z");
this.name = "facebook-facebookuser.zip";
this.name = name;
this.size = MINIMUM_FILE_SIZE;
this._entriesPathHash = new Map();
dataFilePairs.forEach(([path, dataset]) =>
this.addJsonEntry(path, dataset)
);
}

async getEntries() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ const commonJsonFiles = commonStructure
});

async function analyzeZipWithFiles(files) {
const zipFile = new ZipFileMock();
const dataFilePairs = [];
if (files.length > 0) {
files.forEach((jsonPath) => {
zipFile.addJsonEntry(jsonPath, { foo: "bar" });
dataFilePairs.push([jsonPath, { foo: "bar" }]);
});
}
const zipFile = new ZipFileMock(dataFilePairs);
const { analysisResult } = await runAnalysisForExport(
JSONFileNamesAnalysis,
zipFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import ReportMetadataReport from "../../src/views/ministories/reportMetadata";
import { createInteractedWithAdvertisersDataset } from "../datasets/interacted-with-advertisers-data";
import { createLanguageSettingsData } from "../datasets/language-and-locale-data";
import { createOffFacebookEventsSimpleData } from "../datasets/off-facebook-events-data";
import { MINIMUM_FILE_SIZE } from "@polypoly-eu/poly-import";
import { MINIMUM_FILE_SIZE, ZipFileMock } from "@polypoly-eu/poly-import";
import { runAnalysisForExport } from "../utils/analyses-execution";
import {
expectActiveAnalysis,
expectAnalysisSuccessStatus,
} from "../utils/analysis-assertions";
import { createMockedZip } from "../utils/data-creation";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can createMockedZip be removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, from all over? It's used in some other places. I'd have to check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it can be removed. It's essentially doing what the new ctor is doing. Only... It's all over, as said. I'll probably just refactor it to avoid extensive changes.


describe("Report metadata analysis", () => {
const preferedLanguage = {
Expand All @@ -26,7 +25,7 @@ describe("Report metadata analysis", () => {
let jsonReport = null;

beforeAll(async () => {
const zipFile = createMockedZip([
const zipFile = new ZipFileMock([
[
OFF_FACEBOOK_EVENTS_FILE_PATH,
createOffFacebookEventsSimpleData(),
Expand Down
4 changes: 1 addition & 3 deletions features/facebookImport/test/utils/data-creation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ZipFileMock } from "@polypoly-eu/poly-import";

export function createMockedZip(datasets) {
let zipFile = new ZipFileMock();
datasets.forEach(([path, dataset]) => zipFile.addJsonEntry(path, dataset));
return zipFile;
return new ZipFileMock(datasets);
}

export function zipWithWrongDatasetKey(filePath) {
Expand Down