mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
|
import { validateFeatureNamingExample } from './ProjectForm';
|
||
|
|
||
|
describe('validateFeatureNaming', () => {
|
||
|
test.each(['+', 'valid regex$'])(
|
||
|
`if the featureNamingPatternError prop is present, it's always valid: %s`,
|
||
|
pattern => {
|
||
|
const result = validateFeatureNamingExample({
|
||
|
pattern,
|
||
|
example: 'aohutnasoehutns',
|
||
|
featureNamingPatternError: 'error',
|
||
|
});
|
||
|
|
||
|
expect(result.state).toBe('valid');
|
||
|
}
|
||
|
);
|
||
|
test(`if the pattern is empty, the example is always valid`, () => {
|
||
|
const result = validateFeatureNamingExample({
|
||
|
pattern: '',
|
||
|
example: 'aohutnasoehutns',
|
||
|
featureNamingPatternError: undefined,
|
||
|
});
|
||
|
|
||
|
expect(result.state).toBe('valid');
|
||
|
});
|
||
|
test(`if the example is empty, the it's always valid`, () => {
|
||
|
const result = validateFeatureNamingExample({
|
||
|
pattern: '^dx-[a-z]{1,5}$',
|
||
|
example: '',
|
||
|
featureNamingPatternError: undefined,
|
||
|
});
|
||
|
|
||
|
expect(result.state).toBe('valid');
|
||
|
});
|
||
|
|
||
|
test.each([
|
||
|
['valid', 'dx-logs'],
|
||
|
['invalid', 'axe-battles'],
|
||
|
])(
|
||
|
`if example is %s, the state should be be the same`,
|
||
|
(state, example) => {
|
||
|
const result = validateFeatureNamingExample({
|
||
|
pattern: '^dx-[a-z]{1,5}$',
|
||
|
example,
|
||
|
featureNamingPatternError: undefined,
|
||
|
});
|
||
|
|
||
|
expect(result.state).toBe(state);
|
||
|
}
|
||
|
);
|
||
|
});
|