Expand package limit and feature details
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { formatPackageLimit, getPackageFeatureLabel } from './packageSummary';
|
||||
import {
|
||||
collectPackageFeatures,
|
||||
formatEventUsage,
|
||||
formatPackageLimit,
|
||||
getPackageFeatureLabel,
|
||||
getPackageLimitEntries,
|
||||
} from './packageSummary';
|
||||
|
||||
const t = (key: string, options?: Record<string, unknown> | string) => {
|
||||
if (typeof options === 'string') {
|
||||
return options;
|
||||
}
|
||||
return (options?.defaultValue as string | undefined) ?? key;
|
||||
const template = (options?.defaultValue as string | undefined) ?? key;
|
||||
return template
|
||||
.replace('{{used}}', String(options?.used ?? '{{used}}'))
|
||||
.replace('{{limit}}', String(options?.limit ?? '{{limit}}'));
|
||||
};
|
||||
|
||||
describe('packageSummary helpers', () => {
|
||||
@@ -24,4 +33,28 @@ describe('packageSummary helpers', () => {
|
||||
it('formats numeric package limits', () => {
|
||||
expect(formatPackageLimit(12, t)).toBe('12');
|
||||
});
|
||||
|
||||
it('collects features from package and limit payloads', () => {
|
||||
const result = collectPackageFeatures({
|
||||
features: ['custom_branding'],
|
||||
package_limits: { features: ['reseller_dashboard'] },
|
||||
branding_allowed: true,
|
||||
watermark_allowed: false,
|
||||
} as any);
|
||||
|
||||
expect(result).toEqual(expect.arrayContaining(['custom_branding', 'reseller_dashboard', 'branding_allowed']));
|
||||
});
|
||||
|
||||
it('returns labeled limit entries', () => {
|
||||
const result = getPackageLimitEntries({ max_photos: 120 }, t);
|
||||
|
||||
expect(result[0].label).toBe('Photos');
|
||||
expect(result[0].value).toBe('120');
|
||||
});
|
||||
|
||||
it('formats event usage copy', () => {
|
||||
const result = formatEventUsage(3, 10, t);
|
||||
|
||||
expect(result).toBe('3 of 10 events created');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user