🧪 Add unit tests for useChallongeClient composable and refactor code formatting for readability

This commit is contained in:
2026-01-29 05:09:38 +00:00
parent 568224f2d9
commit 0148d0a1f1
2 changed files with 153 additions and 8 deletions

View File

@@ -1,12 +1,12 @@
/**
* Challonge Client Composable
*
*
* Manages Challonge API client initialization with support for:
* - API v1 and v2.1
* - Multiple authentication methods (API Key, OAuth, Client Credentials)
* - Smart auth selection based on tournament scope
* - Reactive client updates
*
*
* @example
* ```js
* const {
@@ -16,7 +16,7 @@
* switchVersion,
* setScope
* } = useChallongeClient();
*
*
* // Use client for API calls
* await client.value.tournaments.list();
* ```
@@ -38,10 +38,8 @@ export function useChallongeClient(options = {}) {
// Get authentication sources
const { getApiKey } = useChallongeApiKey();
const {
isAuthenticated: isOAuthAuthenticated,
accessToken: oauthToken
} = useChallongeOAuth();
const { isAuthenticated: isOAuthAuthenticated, accessToken: oauthToken } =
useChallongeOAuth();
const {
isAuthenticated: isClientCredsAuthenticated,
accessToken: clientCredsToken
@@ -79,7 +77,9 @@ export function useChallongeClient(options = {}) {
// APPLICATION scope - prefer client credentials
if (isClientCredsAuthenticated.value && clientCredsToken.value) {
if (debugMode.value) {
console.log('🔐 Using Client Credentials token for APPLICATION scope');
console.log(
'🔐 Using Client Credentials token for APPLICATION scope'
);
}
return createChallongeV2Client(
{ token: clientCredsToken.value, type: AuthType.OAUTH },