Refine VPN client instructions and subscription refresh flow
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { parseSubscriptionBody } from '../../src/server/subscription.js';
|
||||
import {
|
||||
parseSubscriptionBody,
|
||||
selectRefreshedServer,
|
||||
} from '../../src/server/subscription.js';
|
||||
|
||||
test('subscription server tags are trimmed for selection', () => {
|
||||
const { servers } = parseSubscriptionBody(JSON.stringify({
|
||||
@@ -10,3 +13,19 @@ test('subscription server tags are trimmed for selection', () => {
|
||||
|
||||
assert.equal(servers[0].tag, 'de-frankfurt');
|
||||
});
|
||||
|
||||
test('refreshed subscription keeps the selected server when its tag still exists', () => {
|
||||
const servers = [{ tag: 'de' }, { tag: 'nl' }];
|
||||
|
||||
assert.equal(selectRefreshedServer('nl', servers), 'nl');
|
||||
});
|
||||
|
||||
test('refreshed subscription selects the first server when the old tag disappeared', () => {
|
||||
const servers = [{ tag: 'de' }, { tag: 'nl' }];
|
||||
|
||||
assert.equal(selectRefreshedServer('old-name', servers), 'de');
|
||||
});
|
||||
|
||||
test('refreshed subscription does not select a server before the first user choice', () => {
|
||||
assert.equal(selectRefreshedServer('', [{ tag: 'de' }]), '');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user