test(cli): system link remove check
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user