mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-11-23 17:27:53 +08:00
- Implemented PlanBadge component with tier-based styling and hover effects. - Created PlanBadgePreview for development, showcasing different badge tiers and palettes. - Added SCSS styles for PlanBadge and its preview. - Updated i18n localization files with new strings for selection actions. - Introduced tests for discovery selection synchronization and model entry removal.
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { removeModelAt } from '../src/features/providers/modelEntries';
|
|
import type { ModelEntryInput } from '../src/features/providers/types';
|
|
|
|
describe('removeModelAt', () => {
|
|
test('resets the last model to a fresh blank row without metadata', () => {
|
|
const entry: ModelEntryInput = {
|
|
name: 'model-a',
|
|
alias: 'alias-a',
|
|
sourceIndex: 4,
|
|
priority: 2,
|
|
image: true,
|
|
thinkingJson: '{"budget":1024}',
|
|
};
|
|
const current = [entry];
|
|
|
|
const next = removeModelAt(current, 0);
|
|
|
|
expect(next).toEqual([{ name: '', alias: '' }]);
|
|
expect(next[0]).not.toBe(entry);
|
|
expect(current).toEqual([entry]);
|
|
expect(entry.name).toBe('model-a');
|
|
expect(entry.sourceIndex).toBe(4);
|
|
});
|
|
|
|
test('removes only the selected index and preserves remaining order and metadata', () => {
|
|
const current: ModelEntryInput[] = [
|
|
{ name: 'same', alias: 'first', sourceIndex: 0 },
|
|
{ name: 'same', alias: 'second', sourceIndex: 1 },
|
|
{ name: 'last', alias: '', priority: 3 },
|
|
];
|
|
const original = [...current];
|
|
|
|
const next = removeModelAt(current, 1);
|
|
|
|
expect(next).toEqual([original[0], original[2]]);
|
|
expect(next[0]).toBe(original[0]);
|
|
expect(next[1]).toBe(original[2]);
|
|
expect(current).toEqual(original);
|
|
});
|
|
|
|
test('repeated removal of a blank row retains exactly one fresh blank row', () => {
|
|
const first = removeModelAt([{ name: '', alias: '' }], 0);
|
|
const second = removeModelAt(first, 0);
|
|
|
|
expect(second).toEqual([{ name: '', alias: '' }]);
|
|
expect(second[0]).not.toBe(first[0]);
|
|
});
|
|
|
|
test('empty input produces a blank row', () => {
|
|
expect(removeModelAt([], 0)).toEqual([{ name: '', alias: '' }]);
|
|
});
|
|
});
|