From deb69bcb959d86db0831a0d64b66a96d7bc48dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20=28JJ=29=20Merelo?= Date: Mon, 17 Oct 2022 10:57:08 +0200 Subject: [PATCH] Eliminate unneeded coupling with zipFile :coffin: --- feature-utils/poly-import/utils/zipfile-mock.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/feature-utils/poly-import/utils/zipfile-mock.js b/feature-utils/poly-import/utils/zipfile-mock.js index 6341c2628b..1db2411d63 100644 --- a/feature-utils/poly-import/utils/zipfile-mock.js +++ b/feature-utils/poly-import/utils/zipfile-mock.js @@ -3,8 +3,7 @@ import { jsonStringifyWithUtfEscape } from "./json-encoding"; //The minimum size of a .ZIP file is 22 bytes export const MINIMUM_FILE_SIZE = 22; export class ZipFileEntryMock { - constructor(zipFile, id, path, content) { - this.zipFile = zipFile; + constructor(id, path, content) { this._id = id; this._path = path; this.content = content; @@ -18,12 +17,11 @@ export class ZipFileEntryMock { } async stat() { - const entryContent = this.zipFile.entries[this._id]; return { getId: () => this._id, getTime: () => "", - getName: () => this._id.substr(this.zipFile.id.length), - getSize: () => entryContent.length, + getName: () => this._path, + getSize: () => this.content.length, isFile: () => true, isDirectory: () => false, }; @@ -70,12 +68,7 @@ export class ZipFileMock { addNamedEntry(fileName, stringContent) { const entryId = this.id + "/" + fileName; - const entry = new ZipFileEntryMock( - this, - entryId, - fileName, - stringContent - ); + const entry = new ZipFileEntryMock(entryId, fileName, stringContent); this._entriesPathHash.set(fileName, entry); }