35302ed273
* [ML] Client side cut over * updating paths and commented code * changes based on review * disabling telemetry tests * fixing start job stylesheets * fixing everything that is broken * fixing types and ml icon order * using icon constant
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import { maxLengthValidator, memoryInputValidator } from './validators';
|
|
|
|
describe('maxLengthValidator', () => {
|
|
test('should allow a valid input', () => {
|
|
expect(maxLengthValidator(2)('xx')).toBe(null);
|
|
});
|
|
|
|
test('should describe an invalid input', () => {
|
|
expect(maxLengthValidator(3)('example')).toEqual({
|
|
maxLength: {
|
|
requiredLength: 3,
|
|
actualLength: 7,
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('memoryInputValidator', () => {
|
|
test('should detect missing units', () => {
|
|
expect(memoryInputValidator()('10')).toEqual({
|
|
invalidUnits: {
|
|
allowedUnits: 'B, KB, MB, GB, TB, PB',
|
|
},
|
|
});
|
|
});
|
|
|
|
test('should accept valid input', () => {
|
|
expect(memoryInputValidator()('100PB')).toEqual(null);
|
|
});
|
|
|
|
test('should accept valid input with custom allowed units', () => {
|
|
expect(memoryInputValidator(['B', 'KB'])('100KB')).toEqual(null);
|
|
});
|
|
|
|
test('should detect not allowed units', () => {
|
|
expect(memoryInputValidator(['B', 'KB'])('100MB')).toEqual({
|
|
invalidUnits: {
|
|
allowedUnits: 'B, KB',
|
|
},
|
|
});
|
|
});
|
|
});
|