From 11fb29ef1c2f4fd98b0b32ac9063723057f101aa Mon Sep 17 00:00:00 2001 From: Ivan Kiral Date: Mon, 9 Sep 2024 07:46:20 +0200 Subject: [PATCH] update syncModel test to check all filenames from constant --- tests/integration/sync/syncModel.test.ts | 41 +++++------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/tests/integration/sync/syncModel.test.ts b/tests/integration/sync/syncModel.test.ts index 9eff4d85..031eadb2 100644 --- a/tests/integration/sync/syncModel.test.ts +++ b/tests/integration/sync/syncModel.test.ts @@ -3,14 +3,7 @@ import * as fsPromises from "fs/promises"; import * as path from "path"; import { describe, expect, it } from "vitest"; -import { - assetFoldersFileName, - collectionsFileName, - contentTypesFileName, - contentTypeSnippetsFileName, - taxonomiesFileName, - webSpotlightFileName, -} from "../../../src/modules/sync/constants/filename.ts"; +import * as fileNames from "../../../src/modules/sync/constants/filename.ts"; import { syncModelRun } from "../../../src/public.ts"; import { expectSameAllEnvData, prepareReferences } from "../importExport/utils/compare.ts"; import { AllEnvData, loadAllEnvData } from "../importExport/utils/envData.ts"; @@ -92,33 +85,15 @@ describe.concurrent("Sync environment from folder", () => { .then(stats => stats.isDirectory()) .catch(() => false); - const typesJsonExists = await fsPromises.stat(`${folderPath}/${contentTypesFileName}`) - .then(stats => stats.isFile()) - .catch(() => false); - const snippetJsonExists = await fsPromises.stat(`${folderPath}/${contentTypeSnippetsFileName}`) - .then(stats => stats.isFile()) - .catch(() => false); - const taxonomiesJsonExists = await fsPromises.stat(`${folderPath}/${taxonomiesFileName}`) - .then(stats => stats.isFile()) - .catch(() => false); + expect(folderExists).toEqual(true); - const webSpotlightJsonExists = await fsPromises.stat(`${folderPath}/${webSpotlightFileName}`) - .then(stats => stats.isFile()) - .catch(() => false); - const assetFoldersJsonExists = await fsPromises.stat(`${folderPath}/${assetFoldersFileName}`) - .then(stats => stats.isFile()) - .catch(() => false); - const collectionsJsonExists = await fsPromises.stat(`${folderPath}/${collectionsFileName}`) - .then(stats => stats.isFile()) - .catch(() => false); + const result = await Promise.all( + Object.entries(fileNames).map(([, filename]) => + fsPromises.stat(`${folderPath}/${filename}`).then(stats => stats.isFile()).catch(() => false) + ), + ); - expect(folderExists).toEqual(true); - expect(typesJsonExists).toEqual(true); - expect(snippetJsonExists).toEqual(true); - expect(taxonomiesJsonExists).toEqual(true); - expect(webSpotlightJsonExists).toEqual(true); - expect(assetFoldersJsonExists).toEqual(true); - expect(collectionsJsonExists).toEqual(true); + expect(result.every(res => res)).toEqual(true); }); it.sequential(