From 6c4a509bba299a11af42637fa468d0aa780d938b Mon Sep 17 00:00:00 2001 From: Remi Date: Wed, 21 Oct 2020 15:28:59 +0200 Subject: [PATCH] refactor(cli): createPlugin --- .../commands/create-plugin/createPlugin.test.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/commands/create-plugin/createPlugin.test.ts b/packages/cli/src/commands/create-plugin/createPlugin.test.ts index 839bd4d433..356b315380 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.test.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.test.ts @@ -21,13 +21,15 @@ import os from 'os'; import del from 'del'; import { createTemporaryPluginFolder, movePlugin } from './createPlugin'; +const id = 'testPluginMock'; + describe('createPlugin', () => { afterAll(() => { mockFs.restore(); }); + describe('createPluginFolder', () => { it('should create a temporary plugin directory in the correct place', async () => { - const id = 'testPlugin'; const tempDir = path.join(os.tmpdir(), id); try { await createTemporaryPluginFolder(tempDir); @@ -39,8 +41,6 @@ describe('createPlugin', () => { }); it('should not create a temporary plugin directory if it already exists', async () => { - const id = 'testPluginMock'; - mockFs({ [id]: {}, }); @@ -53,18 +53,11 @@ describe('createPlugin', () => { describe('movePlugin', () => { it('should move the temporary plugin directory to its final place', async () => { - const id = 'testPluginMock'; - const tempDir = id; - const pluginDir = `/test-temp/plugins/${id}`; - mockFs({ [id]: {}, - 'test-temp': { - plugins: { - testPluginMock: {}, - }, - }, }); + const tempDir = id; + const pluginDir = `/test-temp/plugins/${id}`; await movePlugin(tempDir, pluginDir, id); await expect(fs.pathExists(pluginDir)).resolves.toBe(true);