fix tests

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-07-31 15:27:03 +02:00
parent c186c631b4
commit b0e3b6c074
6 changed files with 19 additions and 12 deletions
@@ -33,8 +33,8 @@ const executeShellCommand = jest.fn();
const commandExists = jest.fn();
const fetchContents = jest.fn();
jest.mock('@backstage/plugin-scaffolder-backend', () => ({
...jest.requireActual('@backstage/plugin-scaffolder-backend'),
jest.mock('@backstage/plugin-scaffolder-node', () => ({
...jest.requireActual('@backstage/plugin-scaffolder-node'),
fetchContents: (...args: any[]) => fetchContents(...args),
executeShellCommand: (...args: any[]) => executeShellCommand(...args),
}));
@@ -15,8 +15,8 @@
*/
const mockRailsTemplater = { run: jest.fn() };
jest.mock('@backstage/plugin-scaffolder-backend', () => ({
...jest.requireActual('@backstage/plugin-scaffolder-backend'),
jest.mock('@backstage/plugin-scaffolder-node', () => ({
...jest.requireActual('@backstage/plugin-scaffolder-node'),
fetchContents: jest.fn(),
}));
jest.mock('./railsNewRunner', () => {
@@ -39,7 +39,7 @@ import os from 'os';
import { resolve as resolvePath } from 'path';
import { PassThrough } from 'stream';
import { createFetchRailsAction } from './index';
import { fetchContents } from '@backstage/plugin-scaffolder-backend';
import { fetchContents } from '@backstage/plugin-scaffolder-node';
describe('fetch:rails', () => {
const integrations = ScmIntegrations.fromConfig(
@@ -17,7 +17,7 @@
const executeShellCommand = jest.fn();
const commandExists = jest.fn();
jest.mock('@backstage/plugin-scaffolder-backend', () => ({
jest.mock('@backstage/plugin-scaffolder-node', () => ({
executeShellCommand: (...args: any[]) => executeShellCommand(...args),
}));
jest.mock(
@@ -14,7 +14,10 @@
* limitations under the License.
*/
jest.mock('./helpers');
jest.mock('@backstage/plugin-scaffolder-node', () => {
const actual = jest.requireActual('@backstage/plugin-scaffolder-node');
return { ...actual, fetchContents: jest.fn() };
});
import os from 'os';
import { resolve as resolvePath } from 'path';
@@ -14,7 +14,10 @@
* limitations under the License.
*/
jest.mock('./helpers');
jest.mock('@backstage/plugin-scaffolder-node', () => {
const actual = jest.requireActual('@backstage/plugin-scaffolder-node');
return { ...actual, fetchFile: jest.fn() };
});
import os from 'os';
import { resolve as resolvePath } from 'path';
@@ -14,6 +14,11 @@
* limitations under the License.
*/
jest.mock('@backstage/plugin-scaffolder-node', () => {
const actual = jest.requireActual('@backstage/plugin-scaffolder-node');
return { ...actual, fetchContents: jest.fn() };
});
import os from 'os';
import { join as joinPath, sep as pathSep } from 'path';
import fs from 'fs-extra';
@@ -32,10 +37,6 @@ import {
TemplateAction,
} from '@backstage/plugin-scaffolder-node';
jest.mock('./helpers', () => ({
fetchContents: jest.fn(),
}));
type FetchTemplateInput = ReturnType<
typeof createFetchTemplateAction
> extends TemplateAction<infer U>