test(cli): system link remove check

This commit is contained in:
Remi
2020-10-22 12:20:47 +02:00
parent a45cea627d
commit 4cc188a2c8
@@ -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();
});