Skip to content

Commit

Permalink
update syncModel test to check all filenames from constant
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Sep 9, 2024
1 parent d47406c commit 11fb29e
Showing 1 changed file with 8 additions and 33 deletions.
41 changes: 8 additions & 33 deletions tests/integration/sync/syncModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 11fb29e

Please sign in to comment.