blob: 5d9c72e4c7901ddc156f63376fb3b96f91ea7543 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect } from 'vitest';
import { getInstallationId, getObfuscatedGoogleAccountId } from './user_id.js';
describe('user_id', () => {
describe('getInstallationId', () => {
it('should return a valid UUID format string', () => {
const installationId = getInstallationId();
expect(installationId).toBeDefined();
expect(typeof installationId).toBe('string');
expect(installationId.length).toBeGreaterThan(0);
// Should return the same ID on subsequent calls (consistent)
const secondCall = getInstallationId();
expect(secondCall).toBe(installationId);
});
});
describe('getObfuscatedGoogleAccountId', () => {
it('should return a non-empty string', () => {
const result = getObfuscatedGoogleAccountId();
expect(result).toBeDefined();
expect(typeof result).toBe('string');
// Should be consistent on subsequent calls
const secondCall = getObfuscatedGoogleAccountId();
expect(secondCall).toBe(result);
});
it('should return empty string when no Google Account ID is cached', () => {
// In a clean test environment, there should be no cached Google Account ID
// so getObfuscatedGoogleAccountId should fall back to installation ID
const googleAccountIdResult = getObfuscatedGoogleAccountId();
// They should be the same when no Google Account ID is cached
expect(googleAccountIdResult).toBe('');
});
});
});
|