mirror of
https://github.com/directus/directus.git
synced 2026-02-15 04:05:17 -05:00
* Move format title to dedicated repo * Move CLI as well * Move create-directus-extension * Move create-directus-project * Move extensions sdk * Move gatsby-source-directus * Move sdk * Remove sdk from jest config * Regen package-lock * Add missing tmp types * Fix test import names * Missed one
28 lines
850 B
TypeScript
28 lines
850 B
TypeScript
import { ensureExtensionDirs } from '../../../src/utils/node/ensure-extension-dirs';
|
|
import { EXTENSION_TYPES } from '../../../src/constants/extensions';
|
|
import { ExtensionType } from '../../../src/types';
|
|
import { dirSync, DirResult } from 'tmp';
|
|
|
|
describe('ensureExtensionDirs', () => {
|
|
let rootDir: DirResult;
|
|
|
|
beforeEach(() => {
|
|
rootDir = dirSync({ unsafeCleanup: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
rootDir.removeCallback();
|
|
});
|
|
|
|
const types = EXTENSION_TYPES as readonly ExtensionType[];
|
|
it('returns undefined if the folders exist', async () => {
|
|
expect(await ensureExtensionDirs(rootDir.name, types)).toBe(undefined);
|
|
});
|
|
|
|
it('throws an error when a folder cant be opened', () => {
|
|
expect(async () => {
|
|
await ensureExtensionDirs('/.', types);
|
|
}).rejects.toThrow(`Extension folder "/interfaces" couldn't be opened`);
|
|
});
|
|
});
|