From e0880a14e8caa955475d6d3738bb48f387eeebcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 10:08:15 +0200 Subject: [PATCH 01/20] Add test for Telemetry And set up properly jest to work in a jsdom environment --- feature-utils/poly-import/package.json | 7 +++++++ feature-utils/poly-import/test/telemetry.test.js | 14 ++++++++++++++ .../poly-import/utils/performance-telemetry.js | 1 + 3 files changed, 22 insertions(+) create mode 100644 feature-utils/poly-import/test/telemetry.test.js diff --git a/feature-utils/poly-import/package.json b/feature-utils/poly-import/package.json index 94b9d8ba82..3b7150c504 100644 --- a/feature-utils/poly-import/package.json +++ b/feature-utils/poly-import/package.json @@ -6,5 +6,12 @@ "scripts": { "build": "rollup -c rollup.config.js", "test": "jest --coverage" + }, + "jest": { + "verbose": true, + "transform": { + "\\.[jt]sx?$": "babel-jest" + }, + "testEnvironment": "jsdom" } } diff --git a/feature-utils/poly-import/test/telemetry.test.js b/feature-utils/poly-import/test/telemetry.test.js new file mode 100644 index 0000000000..129c3167f1 --- /dev/null +++ b/feature-utils/poly-import/test/telemetry.test.js @@ -0,0 +1,14 @@ +import { Telemetry } from "../src"; + +describe("Telemetry measures performance ", () => { + let telemetry; + beforeAll(() => { + telemetry = new Telemetry(); + }); + + it("Returns increasing elapsed time", () => { + const oldTime = telemetry.elapsedTime(); + expect(oldTime).toBeGreaterThan(0); + expect(telemetry.elapsedTime()).toBeGreaterThan(oldTime); + }); +}); diff --git a/feature-utils/poly-import/utils/performance-telemetry.js b/feature-utils/poly-import/utils/performance-telemetry.js index 02307c55c4..bd9eea4072 100644 --- a/feature-utils/poly-import/utils/performance-telemetry.js +++ b/feature-utils/poly-import/utils/performance-telemetry.js @@ -3,6 +3,7 @@ * * @class */ + export class Telemetry { constructor() { this._creationTime = performance.now(); From 1ebcb7e262e9f8682d7f2c865d784c5ff245f18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 10:26:26 +0200 Subject: [PATCH 02/20] Adds tests for errors Up to 20% coverage now --- .../poly-import/test/polyIn-errors.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 feature-utils/poly-import/test/polyIn-errors.test.js diff --git a/feature-utils/poly-import/test/polyIn-errors.test.js b/feature-utils/poly-import/test/polyIn-errors.test.js new file mode 100644 index 0000000000..5da83850da --- /dev/null +++ b/feature-utils/poly-import/test/polyIn-errors.test.js @@ -0,0 +1,20 @@ +import { FileImportError, FileSelectionError, RefreshFilesError } from "../src"; + +const classData = [ + [FileImportError, "import"], + [FileSelectionError, "select"], + [RefreshFilesError, "refresh"], +]; + +describe("Errors have the right API ", () => { + it("throws correctly", () => { + classData.forEach((err) => { + const thrower = () => { + throw new err[0]("test"); + }; + + expect(thrower).toThrow(err[0]); + expect(thrower).toThrow(new RegExp(err[1])); + }); + }); +}); From 0393c1f0b5e9bddc7d0a5064eeeaea36fa8e5de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 10:34:15 +0200 Subject: [PATCH 03/20] Refactor to avoid DRY --- feature-utils/poly-import/src/errors/polyIn-errors.js | 4 +--- feature-utils/poly-import/test/polyIn-errors.test.js | 11 ++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/feature-utils/poly-import/src/errors/polyIn-errors.js b/feature-utils/poly-import/src/errors/polyIn-errors.js index e752cc8fd8..bba5f781b3 100644 --- a/feature-utils/poly-import/src/errors/polyIn-errors.js +++ b/feature-utils/poly-import/src/errors/polyIn-errors.js @@ -2,26 +2,24 @@ class PolyImportError extends Error { constructor(type, cause) { super(`Failed to ${type} file`); this.cause = cause; + this.name = this.constructor.name; } } export class FileImportError extends PolyImportError { constructor(cause) { super("import", cause); - this.name = "FileImportError"; } } export class FileSelectionError extends PolyImportError { constructor(cause) { super("select", cause); - this.name = "FileSelectionError"; } } export class RefreshFilesError extends PolyImportError { constructor(cause) { super("refresh", cause); - this.name = "RefreshFilesError"; } } diff --git a/feature-utils/poly-import/test/polyIn-errors.test.js b/feature-utils/poly-import/test/polyIn-errors.test.js index 5da83850da..bd5420d3e8 100644 --- a/feature-utils/poly-import/test/polyIn-errors.test.js +++ b/feature-utils/poly-import/test/polyIn-errors.test.js @@ -9,12 +9,13 @@ const classData = [ describe("Errors have the right API ", () => { it("throws correctly", () => { classData.forEach((err) => { - const thrower = () => { + try { throw new err[0]("test"); - }; - - expect(thrower).toThrow(err[0]); - expect(thrower).toThrow(new RegExp(err[1])); + } catch (error) { + expect(error).toBeInstanceOf(err[0]); + expect(error.message).toMatch(new RegExp(err[1])); + expect(error.name).toBe(new err[0]().constructor.name); + } }); }); }); From fb9c9f9d8483f6cfb4da20e0f33dc905349ee4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 10:38:38 +0200 Subject: [PATCH 04/20] :recycle: and test actual cause --- feature-utils/poly-import/test/polyIn-errors.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/feature-utils/poly-import/test/polyIn-errors.test.js b/feature-utils/poly-import/test/polyIn-errors.test.js index bd5420d3e8..3ff7037e8d 100644 --- a/feature-utils/poly-import/test/polyIn-errors.test.js +++ b/feature-utils/poly-import/test/polyIn-errors.test.js @@ -15,6 +15,7 @@ describe("Errors have the right API ", () => { expect(error).toBeInstanceOf(err[0]); expect(error.message).toMatch(new RegExp(err[1])); expect(error.name).toBe(new err[0]().constructor.name); + expect(error.cause).toBe("test"); } }); }); From fc1ec4b962ef08f7544fc4a1dc14722847a47ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 10:45:20 +0200 Subject: [PATCH 05/20] :recycle: to TypeError Seems the right one for an abstract base class :white_check_mark: too --- feature-utils/poly-import/src/importer.js | 2 +- feature-utils/poly-import/test/importer.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 feature-utils/poly-import/test/importer.test.js diff --git a/feature-utils/poly-import/src/importer.js b/feature-utils/poly-import/src/importer.js index 26852f7089..9a2be05c1f 100644 --- a/feature-utils/poly-import/src/importer.js +++ b/feature-utils/poly-import/src/importer.js @@ -3,7 +3,7 @@ import { Telemetry } from "../utils/performance-telemetry"; export class Importer { async import({ zipFile, dataAccount }) { - throw new Error( + throw new TypeError( `Calling abstract base class with ${zipFile}, ${dataAccount}` ); } diff --git a/feature-utils/poly-import/test/importer.test.js b/feature-utils/poly-import/test/importer.test.js new file mode 100644 index 0000000000..a7b59e253c --- /dev/null +++ b/feature-utils/poly-import/test/importer.test.js @@ -0,0 +1,11 @@ +import { Importer } from "../src"; + +describe("Importer can't be instantiated ", () => { + it("throws", () => { + try { + new Importer(); + } catch (e) { + expect(e).toBeInstanceOf(TypeError); + } + }); +}); From 6e3e41b34fcd11c92161a72a4484cc303744a449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 10:48:23 +0200 Subject: [PATCH 06/20] :bug: it actually calls the function --- feature-utils/poly-import/test/importer.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature-utils/poly-import/test/importer.test.js b/feature-utils/poly-import/test/importer.test.js index a7b59e253c..69620efa7f 100644 --- a/feature-utils/poly-import/test/importer.test.js +++ b/feature-utils/poly-import/test/importer.test.js @@ -1,9 +1,9 @@ import { Importer } from "../src"; describe("Importer can't be instantiated ", () => { - it("throws", () => { + it("throws", async () => { try { - new Importer(); + await new Importer().import({ zipFile: null, dataAccount: null }); } catch (e) { expect(e).toBeInstanceOf(TypeError); } From e430caa7eb00634c38cd0e40034cbf66e32047d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 3 Oct 2022 11:47:49 +0200 Subject: [PATCH 07/20] :white_check_mark: storage tests started Added dep for testing --- feature-utils/poly-import/package-lock.json | 58 ++++++++++++++++++- feature-utils/poly-import/package.json | 3 + .../poly-import/test/storage.test.js | 13 +++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 feature-utils/poly-import/test/storage.test.js diff --git a/feature-utils/poly-import/package-lock.json b/feature-utils/poly-import/package-lock.json index fff9a21c01..33a5d1d1f3 100644 --- a/feature-utils/poly-import/package-lock.json +++ b/feature-utils/poly-import/package-lock.json @@ -4,7 +4,63 @@ "requires": true, "packages": { "": { - "name": "@polypoly-eu/poly-import" + "name": "@polypoly-eu/poly-import", + "devDependencies": { + "@polypoly-eu/api": "file:../../platform/feature-api/api" + } + }, + "../../platform/feature-api/api": { + "version": "0.3.1", + "dev": true, + "dependencies": { + "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", + "fast-check": "^2.2.1", + "uuid": "^8.3.2" + }, + "devDependencies": { + "@graphy/core.data.factory": "^4.3.4", + "@graphy/memory.dataset.fast": "^4.3.3", + "@polypoly-eu/dummy-server": "file:../../../dev-utils/dummy-server", + "@rdfjs/data-model": "^1.1.3", + "@rdfjs/dataset": "^1.0.1", + "@types/chai": "^4.2.14", + "@types/chai-as-promised": "^7.1.5", + "@types/n3": "^1.10.3", + "@types/rdfjs__dataset": "^1.0.4", + "@types/uuid": "^8.3.4", + "memfs": "^3.4.1", + "n3": "^1.8.0", + "rdf-data-factory": "^1.0.4" + } + }, + "node_modules/@polypoly-eu/api": { + "resolved": "../../platform/feature-api/api", + "link": true + } + }, + "dependencies": { + "@polypoly-eu/api": { + "version": "file:../../platform/feature-api/api", + "requires": { + "@graphy/core.data.factory": "^4.3.4", + "@graphy/memory.dataset.fast": "^4.3.3", + "@polypoly-eu/dummy-server": "file:../../../dev-utils/dummy-server", + "@rdfjs/data-model": "^1.1.3", + "@rdfjs/dataset": "^1.0.1", + "@types/chai": "^4.2.14", + "@types/chai-as-promised": "^7.1.5", + "@types/n3": "^1.10.3", + "@types/rdfjs__dataset": "^1.0.4", + "@types/uuid": "^8.3.4", + "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", + "fast-check": "^2.2.1", + "memfs": "^3.4.1", + "n3": "^1.8.0", + "rdf-data-factory": "^1.0.4", + "uuid": "^8.3.2" + } } } } diff --git a/feature-utils/poly-import/package.json b/feature-utils/poly-import/package.json index 3b7150c504..025563dded 100644 --- a/feature-utils/poly-import/package.json +++ b/feature-utils/poly-import/package.json @@ -13,5 +13,8 @@ "\\.[jt]sx?$": "babel-jest" }, "testEnvironment": "jsdom" + }, + "devDependencies": { + "@polypoly-eu/api": "file:../../platform/feature-api/api" } } diff --git a/feature-utils/poly-import/test/storage.test.js b/feature-utils/poly-import/test/storage.test.js new file mode 100644 index 0000000000..8758955015 --- /dev/null +++ b/feature-utils/poly-import/test/storage.test.js @@ -0,0 +1,13 @@ +import { MockPod } from "@polypoly-eu/api/dist/mock-pod"; +import { FeatureFileStorage } from "../src"; + +describe("File storage ", () => { + let fileStorage; + beforeAll(() => { + const pod = new MockPod(); + fileStorage = new FeatureFileStorage(pod); + }); + it("can be instantiated", () => { + expect(fileStorage.files).toBeNull; + }); +}); From fb307cdd7b2267c99afefb2c761f8fa90f6fa42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 10 Oct 2022 07:46:10 +0200 Subject: [PATCH 08/20] DRY --- feature-utils/poly-import/test/polyIn-errors.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/feature-utils/poly-import/test/polyIn-errors.test.js b/feature-utils/poly-import/test/polyIn-errors.test.js index 3ff7037e8d..0513fa3d23 100644 --- a/feature-utils/poly-import/test/polyIn-errors.test.js +++ b/feature-utils/poly-import/test/polyIn-errors.test.js @@ -9,13 +9,14 @@ const classData = [ describe("Errors have the right API ", () => { it("throws correctly", () => { classData.forEach((err) => { + const testCause = "test"; try { - throw new err[0]("test"); + throw new err[0](testCause); } catch (error) { expect(error).toBeInstanceOf(err[0]); expect(error.message).toMatch(new RegExp(err[1])); expect(error.name).toBe(new err[0]().constructor.name); - expect(error.cause).toBe("test"); + expect(error.cause).toBe(testCause); } }); }); From 054389347224a48db1650e5781ce03c98aa06e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 10 Oct 2022 07:48:03 +0200 Subject: [PATCH 09/20] :white_check_mark: use destructuring --- feature-utils/poly-import/test/polyIn-errors.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/feature-utils/poly-import/test/polyIn-errors.test.js b/feature-utils/poly-import/test/polyIn-errors.test.js index 0513fa3d23..18c99a8bcf 100644 --- a/feature-utils/poly-import/test/polyIn-errors.test.js +++ b/feature-utils/poly-import/test/polyIn-errors.test.js @@ -8,14 +8,14 @@ const classData = [ describe("Errors have the right API ", () => { it("throws correctly", () => { - classData.forEach((err) => { + classData.forEach(([testClass, testMsg]) => { const testCause = "test"; try { - throw new err[0](testCause); + throw new testClass(testCause); } catch (error) { - expect(error).toBeInstanceOf(err[0]); - expect(error.message).toMatch(new RegExp(err[1])); - expect(error.name).toBe(new err[0]().constructor.name); + expect(error).toBeInstanceOf(testClass); + expect(error.message).toMatch(new RegExp(testMsg)); + expect(error.name).toBe(new testClass().constructor.name); expect(error.cause).toBe(testCause); } }); From ec523e4aaf92e338042d229e84c32223711b2ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 10 Oct 2022 09:41:21 +0200 Subject: [PATCH 10/20] Starting to test with archive But this is going to need some more mock code, so will leave it like this --- feature-utils/poly-import/test/storage.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/feature-utils/poly-import/test/storage.test.js b/feature-utils/poly-import/test/storage.test.js index 8758955015..91e2422054 100644 --- a/feature-utils/poly-import/test/storage.test.js +++ b/feature-utils/poly-import/test/storage.test.js @@ -11,3 +11,16 @@ describe("File storage ", () => { expect(fileStorage.files).toBeNull; }); }); + +describe("Can remove archives ", () => { + let fileStorage; + let fileUri; + beforeAll(async () => { + const pod = new MockPod(); + fileUri = await pod.polyOut.importArchive("noRealFile.zip"); + fileStorage = new FeatureFileStorage(pod); + }); + it("was instantiated", () => { + expect(fileStorage.files).toBeNull; + }); +}); From 20d23bf2a3710b2224f7430ba382d9c0536e07a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 09:00:03 +0200 Subject: [PATCH 11/20] Address comments --- feature-utils/poly-import/utils/performance-telemetry.js | 1 - 1 file changed, 1 deletion(-) diff --git a/feature-utils/poly-import/utils/performance-telemetry.js b/feature-utils/poly-import/utils/performance-telemetry.js index bd9eea4072..02307c55c4 100644 --- a/feature-utils/poly-import/utils/performance-telemetry.js +++ b/feature-utils/poly-import/utils/performance-telemetry.js @@ -3,7 +3,6 @@ * * @class */ - export class Telemetry { constructor() { this._creationTime = performance.now(); From 54c97d6ef1f0b4f6db8fa4150b121b81547ba6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 09:05:36 +0200 Subject: [PATCH 12/20] :rotating_light: via :white_check_mark: --- feature-utils/poly-import/test/storage.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/feature-utils/poly-import/test/storage.test.js b/feature-utils/poly-import/test/storage.test.js index 91e2422054..46b03dc877 100644 --- a/feature-utils/poly-import/test/storage.test.js +++ b/feature-utils/poly-import/test/storage.test.js @@ -12,7 +12,7 @@ describe("File storage ", () => { }); }); -describe("Can remove archives ", () => { +describe("File storage", () => { let fileStorage; let fileUri; beforeAll(async () => { @@ -20,7 +20,8 @@ describe("Can remove archives ", () => { fileUri = await pod.polyOut.importArchive("noRealFile.zip"); fileStorage = new FeatureFileStorage(pod); }); - it("was instantiated", () => { + it("ignores non-existent archives", () => { + expect(fileUri).toBeInstanceOf(string); expect(fileStorage.files).toBeNull; }); }); From 7894305647eb12ee003d17c3c197eb2154e5bde3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 09:15:56 +0200 Subject: [PATCH 13/20] Export protocol regex to use in tests --- feature-utils/poly-import/test/storage.test.js | 2 +- platform/feature-api/api/src/pod-api/uri.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/feature-utils/poly-import/test/storage.test.js b/feature-utils/poly-import/test/storage.test.js index 46b03dc877..864b7e54d3 100644 --- a/feature-utils/poly-import/test/storage.test.js +++ b/feature-utils/poly-import/test/storage.test.js @@ -21,7 +21,7 @@ describe("File storage", () => { fileStorage = new FeatureFileStorage(pod); }); it("ignores non-existent archives", () => { - expect(fileUri).toBeInstanceOf(string); + expect(fileUri).toMatch(/^polypod:/); expect(fileStorage.files).toBeNull; }); }); diff --git a/platform/feature-api/api/src/pod-api/uri.ts b/platform/feature-api/api/src/pod-api/uri.ts index 21da8c1d5e..51b26b066f 100644 --- a/platform/feature-api/api/src/pod-api/uri.ts +++ b/platform/feature-api/api/src/pod-api/uri.ts @@ -9,8 +9,8 @@ export function createUUID(): string { return uuidv4(); } -const polyProtocol = "polypod://"; -const polyProtocolRegex = new RegExp(`^${polyProtocol}`); +export const polyProtocol = "polypod://"; +export const polyProtocolRegex = new RegExp(`^${polyProtocol}`); /** * From 483b00334d23c529aecab9333555aed17e54b865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 09:17:00 +0200 Subject: [PATCH 14/20] Test URI appropriately :white_check_mark: --- feature-utils/poly-import/test/storage.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feature-utils/poly-import/test/storage.test.js b/feature-utils/poly-import/test/storage.test.js index 864b7e54d3..e1beb55269 100644 --- a/feature-utils/poly-import/test/storage.test.js +++ b/feature-utils/poly-import/test/storage.test.js @@ -1,3 +1,4 @@ +import { polyProtocolRegex } from "@polypoly-eu/api"; import { MockPod } from "@polypoly-eu/api/dist/mock-pod"; import { FeatureFileStorage } from "../src"; @@ -21,7 +22,7 @@ describe("File storage", () => { fileStorage = new FeatureFileStorage(pod); }); it("ignores non-existent archives", () => { - expect(fileUri).toMatch(/^polypod:/); + expect(fileUri).toMatch(polyProtocolRegex); expect(fileStorage.files).toBeNull; }); }); From 95d5309cbe541b16a12be87e669e2815806091be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 09:31:01 +0200 Subject: [PATCH 15/20] Non-interface-changing new constructor :recycle: --- feature-utils/poly-import/utils/zipfile-mock.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/feature-utils/poly-import/utils/zipfile-mock.js b/feature-utils/poly-import/utils/zipfile-mock.js index 6341c2628b..b7865c24dc 100644 --- a/feature-utils/poly-import/utils/zipfile-mock.js +++ b/feature-utils/poly-import/utils/zipfile-mock.js @@ -35,12 +35,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() { From 1bd60a1f59352276665a3a35b66b09fc20d85dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 09:37:04 +0200 Subject: [PATCH 16/20] Change to old interface --- feature-utils/poly-import/utils/zipfile-mock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature-utils/poly-import/utils/zipfile-mock.js b/feature-utils/poly-import/utils/zipfile-mock.js index b7865c24dc..9dda563d96 100644 --- a/feature-utils/poly-import/utils/zipfile-mock.js +++ b/feature-utils/poly-import/utils/zipfile-mock.js @@ -36,7 +36,7 @@ export class ZipFileEntryMock { export class ZipFileMock { constructor( - dataFilePairs = [{ "foo.json": { foo: "bar" } }], + dataFilePairs = [["foo.json", { foo: "bar" }]], name = "facebook-facebookuser.zip" ) { this.id = "polypod://de71f571-d90a-45e0-b007-d8f059e0541b"; From b28b87c225a518b03cbf492a53210c8cfaf9b844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Tue, 18 Oct 2022 07:33:16 +0200 Subject: [PATCH 17/20] Revert part of the change which is in #1218 --- feature-utils/poly-import/utils/zipfile-mock.js | 8 +------- .../facebookImport/test/ministory/report-metadata.test.js | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/feature-utils/poly-import/utils/zipfile-mock.js b/feature-utils/poly-import/utils/zipfile-mock.js index cd7ef61681..124208a8fd 100644 --- a/feature-utils/poly-import/utils/zipfile-mock.js +++ b/feature-utils/poly-import/utils/zipfile-mock.js @@ -33,18 +33,12 @@ export class ZipFileEntryMock { } export class ZipFileMock { - constructor( - dataFilePairs = [["foo.json", { foo: "bar" }]], - name = "facebook-facebookuser.zip" - ) { + constructor(name = "facebook-facebookuser.zip") { this.id = "polypod://de71f571-d90a-45e0-b007-d8f059e0541b"; this.time = new Date("2021-09-20T16:37:36.243Z"); this.name = name; this.size = MINIMUM_FILE_SIZE; this._entriesPathHash = new Map(); - dataFilePairs.forEach(([path, dataset]) => - this.addJsonEntry(path, dataset) - ); } async getEntries() { diff --git a/features/facebookImport/test/ministory/report-metadata.test.js b/features/facebookImport/test/ministory/report-metadata.test.js index 6f56887f05..29e238b619 100644 --- a/features/facebookImport/test/ministory/report-metadata.test.js +++ b/features/facebookImport/test/ministory/report-metadata.test.js @@ -44,6 +44,7 @@ describe("Report metadata analysis", () => { ), ], ]); + console.log(zipFile); const { facebookAccount, analysisResult } = await runAnalysisForExport( ReportMetadataAnalysis, zipFile From fac7da3dac43c712f60ea7a4a091412b9fb250ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20Merelo=20Guerv=C3=B3s?= Date: Mon, 31 Oct 2022 10:10:44 +0100 Subject: [PATCH 18/20] Update feature-utils/poly-import/test/importer.test.js Co-authored-by: irstavr --- feature-utils/poly-import/test/importer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature-utils/poly-import/test/importer.test.js b/feature-utils/poly-import/test/importer.test.js index 69620efa7f..3c04748f86 100644 --- a/feature-utils/poly-import/test/importer.test.js +++ b/feature-utils/poly-import/test/importer.test.js @@ -1,7 +1,7 @@ import { Importer } from "../src"; describe("Importer can't be instantiated ", () => { - it("throws", async () => { + it("throws a TypeError", async () => { try { await new Importer().import({ zipFile: null, dataAccount: null }); } catch (e) { From 5ac68ff4c2f066bd8fb1719301809d624f8752ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20Merelo=20Guerv=C3=B3s?= Date: Mon, 31 Oct 2022 10:11:12 +0100 Subject: [PATCH 19/20] Update feature-utils/poly-import/test/polyIn-errors.test.js Co-authored-by: irstavr --- feature-utils/poly-import/test/polyIn-errors.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature-utils/poly-import/test/polyIn-errors.test.js b/feature-utils/poly-import/test/polyIn-errors.test.js index 18c99a8bcf..bfd57cca5e 100644 --- a/feature-utils/poly-import/test/polyIn-errors.test.js +++ b/feature-utils/poly-import/test/polyIn-errors.test.js @@ -7,7 +7,7 @@ const classData = [ ]; describe("Errors have the right API ", () => { - it("throws correctly", () => { + it("throw correctly their type errors", () => { classData.forEach(([testClass, testMsg]) => { const testCause = "test"; try { From e1979e10a5ade4b29b6c018cb4bfd77654a78a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20Merelo=20Guerv=C3=B3s?= Date: Mon, 31 Oct 2022 10:12:45 +0100 Subject: [PATCH 20/20] Update feature-utils/poly-import/test/storage.test.js Co-authored-by: irstavr --- feature-utils/poly-import/test/storage.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature-utils/poly-import/test/storage.test.js b/feature-utils/poly-import/test/storage.test.js index e1beb55269..0d796dfff5 100644 --- a/feature-utils/poly-import/test/storage.test.js +++ b/feature-utils/poly-import/test/storage.test.js @@ -8,7 +8,7 @@ describe("File storage ", () => { const pod = new MockPod(); fileStorage = new FeatureFileStorage(pod); }); - it("can be instantiated", () => { + it("when instantiated there are no files stored", () => { expect(fileStorage.files).toBeNull; }); });