Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
44
frontend/tests/providerConcurrency.test.ts
Normal file
44
frontend/tests/providerConcurrency.test.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { describe, expect, test } from 'vitest';
|
||||
import {
|
||||
appendLatestProviderRecord,
|
||||
replaceLatestProviderRecord,
|
||||
} from '../src/services/api/providers';
|
||||
|
||||
const mergeRecord = (raw: unknown, payload: Record<string, unknown>) => ({
|
||||
...(raw as Record<string, unknown> | undefined),
|
||||
...payload,
|
||||
});
|
||||
|
||||
describe('provider list concurrency', () => {
|
||||
test('preserves concurrent additions while appending a provider', () => {
|
||||
const latest = [
|
||||
{ 'api-key': 'existing', custom: 'keep' },
|
||||
{ 'api-key': 'concurrent', custom: 'also-keep' },
|
||||
];
|
||||
|
||||
expect(appendLatestProviderRecord(latest, { 'api-key': 'created' }, mergeRecord)).toEqual([
|
||||
{ 'api-key': 'existing', custom: 'keep' },
|
||||
{ 'api-key': 'concurrent', custom: 'also-keep' },
|
||||
{ 'api-key': 'created' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('replaces only the selected provider in the latest list', () => {
|
||||
const latest = [
|
||||
{ 'api-key': 'existing', custom: 'keep' },
|
||||
{ 'api-key': 'concurrent', custom: 'also-keep' },
|
||||
];
|
||||
|
||||
expect(
|
||||
replaceLatestProviderRecord(
|
||||
latest,
|
||||
(record) => record['api-key'] === 'existing',
|
||||
{ 'api-key': 'updated' },
|
||||
mergeRecord
|
||||
)
|
||||
).toEqual([
|
||||
{ 'api-key': 'updated', custom: 'keep' },
|
||||
{ 'api-key': 'concurrent', custom: 'also-keep' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue