♻️ removal of '.testing.ts' file extensions in favour of mocks (#4632)

This commit is contained in:
Matiss Janis Aboltins
2025-03-18 06:13:11 +00:00
committed by GitHub
parent c8813e9953
commit 5fdaa98249
22 changed files with 32 additions and 36 deletions

View File

@@ -1,7 +1,5 @@
module.exports = {
moduleFileExtensions: [
'testing.js',
'testing.ts',
'api.js',
'api.ts',
'api.tsx',

View File

@@ -1,7 +1,5 @@
module.exports = {
moduleFileExtensions: [
'testing.js',
'testing.ts',
'electron.js',
'electron.ts',
'mjs',

View File

@@ -1,7 +1,5 @@
module.exports = {
moduleFileExtensions: [
'testing.js',
'testing.ts',
'web.js',
'web.ts',
'web.tsx',

View File

@@ -15,7 +15,10 @@ import * as rules from '../server/transactions/transaction-rules';
import { updateVersion } from '../server/update';
import { resetTracer, tracer } from '../shared/test-helpers';
jest.mock('../platform/client/fetch');
jest.mock('../platform/exceptions');
jest.mock('../platform/server/asyncStorage');
jest.mock('../platform/server/connection');
jest.mock('../server/post');
// By default, syncing is disabled

View File

@@ -1,5 +1,5 @@
// @ts-strict-ignore
import type * as T from '..';
import type * as T from '../index.d';
let listeners = new Map();
let serverHandler = null;

View File

@@ -5,7 +5,7 @@ import { v4 as uuidv4 } from 'uuid';
import { captureException, captureBreadcrumb } from '../../exceptions';
import * as undo from '../undo';
import type * as T from '.';
import type * as T from './index.d';
const replyHandlers = new Map();
const listeners = new Map();
@@ -199,6 +199,6 @@ export const unlisten: T.Unlisten = function (name) {
listeners.set(name, []);
};
export const clearServer: T.ClearServer = async function () {
//
};
export const initServer: T.InitServer = async function () {};
export const serverPush: T.ServerPush = async function () {};
export const clearServer: T.ClearServer = async function () {};

View File

@@ -1,2 +0,0 @@
// eslint-disable-next-line no-restricted-imports
export * from './__mocks__/index.web';

View File

@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
import * as undo from '../undo';
import type * as T from '.';
import type * as T from './index.d';
const replyHandlers = new Map();
const listeners = new Map();
@@ -145,3 +145,5 @@ export const clearServer: T.ClearServer = async function () {
return new Promise(closeSocket);
}
};
export const initServer: T.InitServer = async function () {};
export const serverPush: T.ServerPush = async function () {};

View File

@@ -1,7 +1,6 @@
// @ts-strict-ignore
import { GlobalPrefsJson } from '../../../types/prefs';
import * as T from '.';
import { GlobalPrefsJson } from '../../../../types/prefs';
import * as T from '../index.d';
const store: GlobalPrefsJson = {};

View File

@@ -5,7 +5,7 @@ import { join } from 'path';
import { GlobalPrefsJson } from '../../../types/prefs';
import * as lootFs from '../fs';
import * as T from '.';
import * as T from './index.d';
const getStorePath = () => join(lootFs.getDataDir(), 'global-store.json');
let store: GlobalPrefsJson;

View File

@@ -2,7 +2,7 @@
import { GlobalPrefsJson } from '../../../types/prefs';
import { getDatabase } from '../indexeddb';
import * as T from '.';
import * as T from './index.d';
export const init: T.Init = function () {};

View File

@@ -1,5 +1,4 @@
// @ts-strict-ignore
import type * as T from '.';
import type * as T from '../index.d';
let events = [];
@@ -9,10 +8,6 @@ export const send: T.Send = function (type, args) {
events.push([type, args]);
};
export const getEvents: T.GetEvents = function () {
return events;
};
export const resetEvents: T.ResetEvents = function () {
events = [];
};

View File

@@ -1,4 +1,4 @@
import type * as T from '.';
import type * as T from './index.d';
export const init: T.Init = function () {};

View File

@@ -13,9 +13,6 @@ export function send<K extends keyof ServerEvents>(
): void;
export type Send = typeof send;
export function getEvents(): unknown[];
export type GetEvents = typeof getEvents;
export function getNumClients(): number;
export type GetNumClients = typeof getNumClients;

View File

@@ -3,7 +3,7 @@ import { APIError } from '../../../server/errors';
import { runHandler, isMutating } from '../../../server/mutators';
import { captureException } from '../../exceptions';
import type * as T from '.';
import type * as T from './index.d';
function coerceError(error) {
if (error.type && error.type === 'APIError') {
@@ -84,3 +84,5 @@ export const getNumClients: T.GetNumClients = function () {
export const send: T.Send = function (name, args) {
process.parentPort.postMessage({ type: 'push', name, args });
};
export const resetEvents: T.ResetEvents = function () {};

View File

@@ -3,7 +3,7 @@ import { APIError } from '../../../server/errors';
import { runHandler, isMutating } from '../../../server/mutators';
import { captureException } from '../../exceptions';
import type * as T from '.';
import type * as T from './index.d';
function getGlobalObject() {
const obj =
@@ -135,3 +135,5 @@ export const send: T.Send = function (name, args) {
export const getNumClients = function () {
return 1;
};
export const resetEvents: T.ResetEvents = function () {};

View File

@@ -1,4 +0,0 @@
export function fetch(
input: RequestInfo | URL,
options?: unknown,
): Promise<Response>;

View File

@@ -304,7 +304,9 @@ export async function upload() {
? { 'X-ACTUAL-ENCRYPT-META': JSON.stringify(uploadMeta) }
: null),
...(groupId ? { 'X-ACTUAL-GROUP-ID': groupId } : null),
},
// TODO: fix me
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
body: uploadContent,
});
} catch (err) {