Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
32
frontend/tests/credentialWeight.test.ts
Normal file
32
frontend/tests/credentialWeight.test.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { describe, expect, test } from 'vitest';
|
||||
import {
|
||||
MAX_CREDENTIAL_WEIGHT,
|
||||
parseCredentialWeightText,
|
||||
readCredentialWeight,
|
||||
validateCredentialWeightText,
|
||||
} from '../src/utils/credentialWeight';
|
||||
|
||||
describe('credential weight validation', () => {
|
||||
test('accepts the default range and non-positive scheduling exclusions', () => {
|
||||
expect(parseCredentialWeightText('')).toBeUndefined();
|
||||
expect(parseCredentialWeightText('1')).toBe(1);
|
||||
expect(parseCredentialWeightText('0')).toBe(0);
|
||||
expect(parseCredentialWeightText('-2')).toBe(-2);
|
||||
expect(parseCredentialWeightText(String(MAX_CREDENTIAL_WEIGHT))).toBe(MAX_CREDENTIAL_WEIGHT);
|
||||
});
|
||||
|
||||
test('rejects non-integers and values above the backend maximum', () => {
|
||||
expect(validateCredentialWeightText('1.5')).toBe('integer');
|
||||
expect(validateCredentialWeightText('1e3')).toBe('integer');
|
||||
expect(validateCredentialWeightText(String(MAX_CREDENTIAL_WEIGHT + 1))).toBe('max');
|
||||
expect(parseCredentialWeightText('1.5')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('reads only valid numeric response fields', () => {
|
||||
expect(readCredentialWeight(7)).toBe(7);
|
||||
expect(readCredentialWeight(0)).toBe(0);
|
||||
expect(readCredentialWeight(' 7 ')).toBe(7);
|
||||
expect(readCredentialWeight('7.5')).toBeUndefined();
|
||||
expect(readCredentialWeight(MAX_CREDENTIAL_WEIGHT + 1)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue