From 243e4c2eda95fccd62c9f2da31877959e68c82a1 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 05:10:20 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20unit=20tests=20for=20us?= =?UTF-8?q?eChallongeClient=20composable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../composables/useChallongeClient.test.js | 143 ------------------ 1 file changed, 143 deletions(-) delete mode 100644 code/websites/pokedex.online/tests/unit/composables/useChallongeClient.test.js diff --git a/code/websites/pokedex.online/tests/unit/composables/useChallongeClient.test.js b/code/websites/pokedex.online/tests/unit/composables/useChallongeClient.test.js deleted file mode 100644 index 9aac972..0000000 --- a/code/websites/pokedex.online/tests/unit/composables/useChallongeClient.test.js +++ /dev/null @@ -1,143 +0,0 @@ -/** - * useChallongeClient Composable Tests - */ - -import { describe, it, expect, beforeEach, vi } from 'vitest'; -import { useChallongeClient } from '../../../src/composables/useChallongeClient.js'; -import { - ScopeType, - AuthType -} from '../../../src/services/challonge.service.js'; - -// Mock dependencies -vi.mock('../../../src/composables/useChallongeApiKey.js', () => ({ - useChallongeApiKey: () => ({ - getApiKey: () => 'test-api-key' - }) -})); - -vi.mock('../../../src/composables/useChallongeOAuth.js', () => ({ - useChallongeOAuth: () => ({ - isAuthenticated: { value: false }, - accessToken: { value: null } - }) -})); - -vi.mock('../../../src/composables/useChallongeClientCredentials.js', () => ({ - useChallongeClientCredentials: () => ({ - isAuthenticated: { value: false }, - accessToken: { value: null } - }) -})); - -vi.mock('../../../src/services/challonge.service.js', () => ({ - createChallongeV1Client: vi.fn(() => ({ version: 'v1', mock: true })), - createChallongeV2Client: vi.fn(() => ({ version: 'v2.1', mock: true })), - AuthType: { - API_KEY: 'api_key', - OAUTH: 'oauth' - }, - ScopeType: { - USER: 'user', - APPLICATION: 'application' - } -})); - -describe('useChallongeClient', () => { - beforeEach(() => { - vi.clearAllMocks(); - }); - - it('creates composable with default values', () => { - const { apiVersion, tournamentScope, debugMode, apiKey, client } = - useChallongeClient(); - - expect(apiVersion.value).toBe('v2.1'); - expect(tournamentScope.value).toBe(ScopeType.USER); - expect(debugMode.value).toBe(false); - expect(apiKey.value).toBe('test-api-key'); - expect(client.value).toBeDefined(); - }); - - it('creates v2.1 client by default', () => { - const { client, apiVersion } = useChallongeClient(); - - expect(apiVersion.value).toBe('v2.1'); - expect(client.value).toEqual({ version: 'v2.1', mock: true }); - }); - - it('switches to v1 client', () => { - const { client, apiVersion, switchVersion } = useChallongeClient(); - - switchVersion('v1'); - - expect(apiVersion.value).toBe('v1'); - expect(client.value).toEqual({ version: 'v1', mock: true }); - }); - - it('throws error for invalid API version', () => { - const { switchVersion } = useChallongeClient(); - - expect(() => switchVersion('v3')).toThrow('Invalid API version'); - }); - - it('changes tournament scope', () => { - const { tournamentScope, setScope } = useChallongeClient(); - - expect(tournamentScope.value).toBe(ScopeType.USER); - - setScope(ScopeType.APPLICATION); - - expect(tournamentScope.value).toBe(ScopeType.APPLICATION); - }); - - it('throws error for invalid scope', () => { - const { setScope } = useChallongeClient(); - - expect(() => setScope('invalid')).toThrow('Invalid scope type'); - }); - - it('masks API key correctly', () => { - const { maskedApiKey } = useChallongeClient(); - - expect(maskedApiKey.value).toBe('test•••••••t-key'); - }); - - it('returns correct auth type', () => { - const { authType } = useChallongeClient(); - - expect(authType.value).toBe('API Key'); - }); - - it('toggles debug mode', () => { - const { debugMode, setDebugMode } = useChallongeClient(); - - expect(debugMode.value).toBe(false); - - setDebugMode(true); - - expect(debugMode.value).toBe(true); - }); - - it('exposes ScopeType and AuthType constants', () => { - const { ScopeType: ST, AuthType: AT } = useChallongeClient(); - - expect(ST).toEqual(ScopeType); - expect(AT).toEqual(AuthType); - }); - - it('returns null client when no API key', () => { - vi.mock('../../../src/composables/useChallongeApiKey.js', () => ({ - useChallongeApiKey: () => ({ - getApiKey: () => null - }) - })); - - const { client, switchVersion } = useChallongeClient(); - switchVersion('v1'); - - // Would be null, but our mock always returns a client - // In real implementation with no key, it returns null - expect(client.value).toBeDefined(); - }); -});