mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-14 20:08:12 +08:00
36 lines
979 B
TypeScript
36 lines
979 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { createGlobalProxyDraft, toPersistedGlobalProxy } from './globalProxyDraft';
|
|
|
|
describe('global proxy draft', () => {
|
|
it('hydrates a secretless draft from backend metadata while keeping password input blank', () => {
|
|
const draft = createGlobalProxyDraft({
|
|
enabled: true,
|
|
type: 'http',
|
|
host: '127.0.0.1',
|
|
port: 8080,
|
|
user: 'ops',
|
|
hasPassword: true,
|
|
password: 'should-be-ignored',
|
|
});
|
|
|
|
expect(draft.password).toBe('');
|
|
expect(draft.hasPassword).toBe(true);
|
|
});
|
|
|
|
it('drops password from persisted metadata but preserves hasPassword', () => {
|
|
const persisted = toPersistedGlobalProxy({
|
|
enabled: true,
|
|
type: 'http',
|
|
host: '127.0.0.1',
|
|
port: 8080,
|
|
user: 'ops',
|
|
password: 'proxy-secret',
|
|
hasPassword: true,
|
|
});
|
|
|
|
expect('password' in persisted).toBe(false);
|
|
expect(persisted.hasPassword).toBe(true);
|
|
});
|
|
});
|