Add subscription info refresh endpoint and UI stats
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
formatConnectionDuration,
|
||||
localProxyUrls,
|
||||
subscriptionDomain,
|
||||
subscriptionDaysLeft,
|
||||
subscriptionUsage,
|
||||
} from '../../src/web/utils/clientControls.js';
|
||||
|
||||
test('connection button chooses the only valid client action', () => {
|
||||
@@ -44,3 +46,21 @@ test('local proxy defaults to the macOS client port', () => {
|
||||
http: 'http://127.0.0.1:8082',
|
||||
});
|
||||
});
|
||||
|
||||
test('subscription usage combines traffic and caps progress', () => {
|
||||
assert.deepEqual(subscriptionUsage({ upload: 30, download: 80, total: 100, expire: 2 }), {
|
||||
upload: 30,
|
||||
download: 80,
|
||||
total: 100,
|
||||
used: 110,
|
||||
percent: 100,
|
||||
expiresAt: new Date(2000),
|
||||
});
|
||||
});
|
||||
|
||||
test('subscription expiry uses Russian day forms', () => {
|
||||
const now = Date.parse('2026-07-11T00:00:00Z');
|
||||
assert.equal(subscriptionDaysLeft(new Date('2026-07-12T00:00:00Z'), now), 'остался 1 день');
|
||||
assert.equal(subscriptionDaysLeft(new Date('2026-07-13T00:00:00Z'), now), 'осталось 2 дня');
|
||||
assert.equal(subscriptionDaysLeft(new Date('2026-07-16T00:00:00Z'), now), 'осталось 5 дней');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user