refactor: standardize runtime guard patterns with lodash-es (#154)
* refactor(ui): replace runtime type guards with lodash-es predicates * refactor(runtime): migrate typeof checks to lodash-es in core modules * refactor(ipc): standardize runtime guards with lodash-es * test(refactor): align runtime guard checks with lodash-es * docs(agents): add lodash-es runtime guard skill summary
This commit is contained in:
33 files changed
+303
-208
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { isString } from 'lodash-es';
|
||||
|
||||
// Mock module to test timeout behavior
|
||||
describe('GoogleAPIService Timeout', () => {
|
||||
@@ -92,13 +93,13 @@ describe('GoogleAPIService OAuth clients', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (typeof originalOauthClientsEnv === 'string') {
|
||||
if (isString(originalOauthClientsEnv)) {
|
||||
process.env.ANTIGRAVITY_OAUTH_CLIENTS = originalOauthClientsEnv;
|
||||
} else {
|
||||
delete process.env.ANTIGRAVITY_OAUTH_CLIENTS;
|
||||
}
|
||||
|
||||
if (typeof originalActiveOauthClientEnv === 'string') {
|
||||
if (isString(originalActiveOauthClientEnv)) {
|
||||
process.env.ANTIGRAVITY_OAUTH_CLIENT_KEY = originalActiveOauthClientEnv;
|
||||
} else {
|
||||
delete process.env.ANTIGRAVITY_OAUTH_CLIENT_KEY;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import * as matchers from '@testing-library/jest-dom/matchers';
|
||||
import { isUndefined } from 'lodash-es';
|
||||
import { expect, vi } from 'vitest';
|
||||
|
||||
expect.extend(matchers);
|
||||
|
||||
// Mock window and localStorage for Node environment
|
||||
if (typeof window === 'undefined') {
|
||||
if (isUndefined((globalThis as { window?: unknown }).window)) {
|
||||
global.window = {
|
||||
matchMedia: vi.fn().mockImplementation((query) => ({
|
||||
matches: false,
|
||||
|
||||
Reference in new issue
Block a user