From 4cc188a2c81f0e88c835b6da0faecca9e871ae06 Mon Sep 17 00:00:00 2001 From: Remi Date: Thu, 22 Oct 2020 12:20:47 +0200 Subject: [PATCH] test(cli): system link remove check --- .../src/commands/remove-plugin/removePlugin.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/remove-plugin/removePlugin.test.ts b/packages/cli/src/commands/remove-plugin/removePlugin.test.ts index 7b9857a337..076f54402b 100644 --- a/packages/cli/src/commands/remove-plugin/removePlugin.test.ts +++ b/packages/cli/src/commands/remove-plugin/removePlugin.test.ts @@ -16,6 +16,7 @@ import fse from 'fs-extra'; import path from 'path'; +import mockFs from 'mock-fs'; import { paths } from '../../lib/paths'; import { addExportStatement, capitalize } from '../create-plugin/createPlugin'; import { addCodeownersEntry } from '../../lib/codeowners'; @@ -27,8 +28,6 @@ import { removePluginFromCodeOwners, } from './removePlugin'; -const mockFs = require('mock-fs'); - const BACKSTAGE = `@backstage`; const testPluginName = 'yarn-test-package'; const testPluginPackage = `${BACKSTAGE}/plugin-${testPluginName}`; @@ -213,19 +212,22 @@ describe('removePlugin', () => { it('removes system link from @backstage', async () => { const symLink = `plugin-${testPluginName}`; const testSymLinkPath = `/node_modules/@backstage/${symLink}`; - - mkTestPluginDir(testDirPath); + const mockedTestDirPath = path.join('/plugins', testPluginName); mockFs({ + '/plugins': { + [testPluginName]: {}, + }, '/node_modules': { '@backstage': { [symLink]: mockFs.symlink({ - path: testDirPath, + path: mockedTestDirPath, }), }, }, }); + expect(fse.existsSync(testSymLinkPath)).toBeTruthy(); await removeSymLink(testSymLinkPath); expect(fse.existsSync(testSymLinkPath)).toBeFalsy(); });