Files
hive/frontend/node_modules/ts-jest/dist/utils/memoize.js
anthonyrawlins aacb45156b Set up comprehensive frontend testing infrastructure
- Install Jest for unit testing with React Testing Library
- Install Playwright for end-to-end testing
- Configure Jest with proper TypeScript support and module mapping
- Create test setup files and utilities for both unit and e2e tests

Components:
* Jest configuration with coverage thresholds
* Playwright configuration with browser automation
* Unit tests for LoginForm, AuthContext, and useSocketIO hook
* E2E tests for authentication, dashboard, and agents workflows
* GitHub Actions workflow for automated testing
* Mock data and API utilities for consistent testing
* Test documentation with best practices

Testing features:
- Unit tests with 70% coverage threshold
- E2E tests with API mocking and user journey testing
- CI/CD integration for automated test runs
- Cross-browser testing support with Playwright
- Authentication system testing end-to-end

🚀 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-11 14:06:34 +10:00

61 lines
2.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Memoize = Memoize;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cacheProp = Symbol.for('[memoize]');
/**
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function Memoize(keyBuilder) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (_, propertyKey, descriptor) => {
if (descriptor.value != null) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || ((v) => v));
}
else if (descriptor.get != null) {
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (() => propertyKey));
}
};
}
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function ensureCache(target, reset = false) {
if (reset || !target[cacheProp]) {
Object.defineProperty(target, cacheProp, {
value: Object.create(null),
configurable: true,
});
}
return target[cacheProp];
}
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function ensureChildCache(target, key, reset = false) {
const dict = ensureCache(target);
if (reset || !dict[key]) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dict[key] = new Map();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return dict[key];
}
function memoize(namespace,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
func,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
keyBuilder) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function (...args) {
const cache = ensureChildCache(this, namespace);
const key = keyBuilder.apply(this, args);
if (cache.has(key))
return cache.get(key);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res = func.apply(this, args);
cache.set(key, res);
return res;
};
}