Skip to content

Commit

Permalink
fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Del Core committed Sep 17, 2024
1 parent 52fe62a commit be0ed7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ module.exports = {
'jest-watch-typeahead/testname',
],
moduleNameMapper: {
// '@hypermod/(.*)\\.js': '<rootDir>/packages/$1/src',
'(.+)\\.js$': '$1',

'@hypermod/(.*)$': '<rootDir>/packages/$1/src',
'@codeshift/(.*)$': '<rootDir>/packages/$1/src',
},
Expand Down
14 changes: 7 additions & 7 deletions packages/fetcher/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('fetcher', () => {
let mockMatchedPaths: string[] = [];

beforeEach(() => {
mockMatchedPaths = [path.join(mockBasePath, 'hypermod.config.js')];
mockMatchedPaths = [path.join(mockBasePath, 'hypermod.config.ts')];

(globby as unknown as jest.Mock).mockImplementation(() =>
Promise.resolve(mockMatchedPaths),
Expand All @@ -34,10 +34,10 @@ describe('fetcher', () => {

describe('fetchConfig', () => {
it('fetches config with default export', async () => {
const mockFilePath = `${__dirname}/path/to/hypermod.config.js`;
const mockFilePath = `${__dirname}/path/to/hypermod.config.ts`;

jest.mock(
`${__dirname}/path/to/hypermod.config.js`,
`${__dirname}/path/to/hypermod.config.ts`,
() => ({ __esModule: true, default: mockConfig }),
{ virtual: true },
);
Expand All @@ -50,7 +50,7 @@ describe('fetcher', () => {

it('fetches config with named export', async () => {
jest.mock(
path.join(mockBasePath, 'hypermod.config.js'),
path.join(mockBasePath, 'hypermod.config.ts'),
() => mockConfig,
{
virtual: true,
Expand All @@ -61,7 +61,7 @@ describe('fetcher', () => {

expect(configMeta!.config).toEqual(mockConfig);
expect(configMeta!.filePath).toEqual(
path.join(mockBasePath, 'hypermod.config.js'),
path.join(mockBasePath, 'hypermod.config.ts'),
);
});

Expand Down Expand Up @@ -102,7 +102,7 @@ describe('fetcher', () => {

describe('fetchPackage', () => {
it('correctly fetches package and returns a config', async () => {
const mockFilePath = 'path/to/config.hypermod.js';
const mockFilePath = 'path/to/config.hypermod.ts';
const mockPackageManager = {
install: jest.fn(),
getInfo: jest.fn().mockReturnValue({ location: mockFilePath }),
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('fetcher', () => {

expect(configMeta!.config).toEqual(mockConfig);
expect(configMeta!.filePath).toEqual(
mockBasePath + '/hypermod.config.js',
mockBasePath + '/hypermod.config.ts',
);
});

Expand Down

0 comments on commit be0ed7b

Please sign in to comment.