mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
30 lines
959 B
JavaScript
30 lines
959 B
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
CLOUD_VOICE_AUTH_STORAGE_KEY,
|
|
readStoredCloudVoiceAuthMode,
|
|
writeStoredCloudVoiceAuthMode,
|
|
} from './cloudVoiceAuth.js';
|
|
|
|
function memoryStorage(seed = {}) {
|
|
const values = new Map(Object.entries(seed));
|
|
return {
|
|
getItem: (key) => values.get(key) ?? null,
|
|
setItem: (key, value) => values.set(key, value),
|
|
};
|
|
}
|
|
|
|
test('cloud voice auth defaults to API key and persists OAuth independently', () => {
|
|
const storage = memoryStorage();
|
|
assert.equal(readStoredCloudVoiceAuthMode(storage), 'api-key');
|
|
assert.equal(writeStoredCloudVoiceAuthMode('oauth', storage), 'oauth');
|
|
assert.equal(readStoredCloudVoiceAuthMode(storage), 'oauth');
|
|
assert.equal(writeStoredCloudVoiceAuthMode('unknown', storage), 'api-key');
|
|
assert.equal(
|
|
readStoredCloudVoiceAuthMode(
|
|
memoryStorage({ [CLOUD_VOICE_AUTH_STORAGE_KEY]: 'oauth' }),
|
|
),
|
|
'oauth',
|
|
);
|
|
});
|