Files
renovate/lib/modules/manager/bun/utils.spec.ts
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00

39 lines
1.4 KiB
TypeScript

import { fileMatchesWorkspaces, filesMatchingWorkspaces } from './utils.ts';
describe('modules/manager/bun/utils', () => {
const pwd = '/project';
describe('fileMatchesWorkspaces', () => {
it('should return false when fileName does not start with pwd', () => {
// This file path doesn't start with the given pwd, so it should return false.
const fileName = '/another-path/package.json';
const workspaces = ['**'];
expect(fileMatchesWorkspaces(pwd, fileName, workspaces)).toBe(false);
});
it('should correctly evaluate fileName when it starts with pwd', () => {
// Here the fileName starts with pwd, so the workspace patterns will be checked.
const fileName = '/project/foo/package.json';
const workspaces = ['foo'];
expect(fileMatchesWorkspaces(pwd, fileName, workspaces)).toBe(true);
});
});
describe('filesMatchingWorkspaces', () => {
const workspaces = ['foo', 'bar'];
const files = [
'/project/foo/package.json',
'/project/bar/package.json',
'/other/baz/package.json', // This should be filtered out since it doesn't start with pwd
];
it('should filter files matching workspaces and pwd', () => {
const result = filesMatchingWorkspaces(pwd, files, workspaces);
expect(result).toEqual([
'/project/foo/package.json',
'/project/bar/package.json',
]);
});
});
});