Merge pull request #15397 from backstage/jhaals/repo-tools

repo-tools/chore: Update tests to pass on windows
This commit is contained in:
Johan Haals
2022-12-22 17:03:35 +01:00
committed by GitHub
2 changed files with 21 additions and 18 deletions
@@ -16,7 +16,7 @@
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { resolve as resolvePath } from 'path';
import { resolve as resolvePath, join as joinPath } from 'path';
import { paths } from '../../paths';
import { Task } from '../../tasks';
import { FactoryRegistry } from '../FactoryRegistry';
@@ -73,7 +73,7 @@ describe('webLibraryPackage factory', () => {
'',
`Creating web-library package ${expectedwebLibraryPackageName}`,
'Checking Prerequisites:',
`availability packages/${expectedwebLibraryPackageName}`,
`availability ${joinPath('packages', expectedwebLibraryPackageName)}`,
'creating temp dir',
'Executing Template:',
'copying .eslintrc.js',
@@ -82,7 +82,7 @@ describe('webLibraryPackage factory', () => {
'templating index.ts.hbs',
'copying setupTests.ts',
'Installing:',
`moving packages/${expectedwebLibraryPackageName}`,
`moving ${joinPath('packages', expectedwebLibraryPackageName)}`,
]);
await expect(
+18 -15
View File
@@ -15,7 +15,7 @@
*/
import mockFs from 'mock-fs';
import { resolve as resolvePath } from 'path';
import { resolve as resolvePath, join as joinPath } from 'path';
import { resolvePackagePath, paths, findPackageDirs } from './paths';
describe('paths', () => {
@@ -61,15 +61,15 @@ describe('paths', () => {
});
it('should return the path to the package if it exists and has a package.json', async () => {
expect(await resolvePackagePath('packages/package-a')).toBe(
'packages/package-a',
joinPath('packages', 'package-a'),
);
expect(await resolvePackagePath('packages/package-b')).toBe(
'packages/package-b',
joinPath('packages', 'package-b'),
);
});
it('should work with absolute paths', async () => {
expect(await resolvePackagePath('/root/packages/package-a')).toBe(
'packages/package-a',
joinPath('packages', 'package-a'),
);
});
it('should return undefined if the pat is not a directory', async () => {
@@ -79,19 +79,19 @@ describe('paths', () => {
describe('findPackageDirs', () => {
it('should return only the given packages', async () => {
expect(await findPackageDirs(['packages/package-a'])).toEqual([
'packages/package-a',
joinPath('packages', 'package-a'),
]);
});
it('should return only the given packages when using glob patterns', async () => {
expect(await findPackageDirs(['packages/*'])).toEqual([
'packages/package-a',
'packages/package-b',
joinPath('packages', 'package-a'),
joinPath('packages', 'package-b'),
]);
expect(await findPackageDirs(['packages/*', 'plugins/*'])).toEqual([
'packages/package-a',
'packages/package-b',
'plugins/plugin-a',
'plugins/plugin-b',
joinPath('packages', 'package-a'),
joinPath('packages', 'package-b'),
joinPath('plugins', 'plugin-a'),
joinPath('plugins', 'plugin-b'),
]);
});
it('should return only the given packages when using absolute paths', async () => {
@@ -100,15 +100,18 @@ describe('paths', () => {
'/root/packages/package-a',
'/root/plugins/plugin-b',
]),
).toEqual(['packages/package-a', 'plugins/plugin-b']);
).toEqual([
joinPath('packages', 'package-a'),
joinPath('plugins', 'plugin-b'),
]);
});
it('should return only the given packages when using absolute paths with glob patterns', async () => {
expect(
await findPackageDirs(['/root/packages/*', '/root/plugins/*-a']),
).toEqual([
'packages/package-a',
'packages/package-b',
'plugins/plugin-a',
joinPath('packages', 'package-a'),
joinPath('packages', 'package-b'),
joinPath('plugins', 'plugin-a'),
]);
});
});