cli-node: refactor to remove mock-fs
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -15,15 +15,17 @@
|
||||
*/
|
||||
|
||||
import { isMonoRepo } from './isMonoRepo';
|
||||
import mockFs from 'mock-fs';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
|
||||
const mockDir = createMockDirectory();
|
||||
|
||||
jest.mock('../paths', () => ({
|
||||
paths: { resolveTargetRoot: (...args: string[]) => mockDir.resolve(...args) },
|
||||
}));
|
||||
|
||||
describe('isMonoRepo', () => {
|
||||
afterEach(() => {
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
it('should detect a monorepo', async () => {
|
||||
mockFs({
|
||||
mockDir.setContent({
|
||||
'package.json': JSON.stringify({
|
||||
name: 'foo',
|
||||
workspaces: {
|
||||
@@ -35,7 +37,7 @@ describe('isMonoRepo', () => {
|
||||
});
|
||||
|
||||
it('should detect a non- monorepo', async () => {
|
||||
mockFs({
|
||||
mockDir.setContent({
|
||||
'package.json': JSON.stringify({
|
||||
name: 'foo',
|
||||
}),
|
||||
@@ -44,7 +46,7 @@ describe('isMonoRepo', () => {
|
||||
});
|
||||
|
||||
it('should return false if package.json is missing', async () => {
|
||||
mockFs({});
|
||||
mockDir.setContent({});
|
||||
await expect(isMonoRepo()).resolves.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user