mirror of
https://github.com/owncast/owncast.git
synced 2024-12-30 21:18:39 +03:00
e50b23d081
* chore(js): be stricter about dead code warnings * chore(js): remove dead code and unused exports * rebase * chore: remove unused files * chore(deps): remove unused prop-types dep * chore(js): remove unused function * chore(deps): remove + check unused deps * chore(js): remove unused exports. Closes #3036
26 lines
875 B
TypeScript
26 lines
875 B
TypeScript
import { generateRndKey } from '../components/admin/config/server/StreamKeys';
|
|
|
|
describe('generateRndKey', () => {
|
|
test('should generate a key that matches the regular expression', () => {
|
|
const key = generateRndKey();
|
|
const regex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#$^&*]).{8,192}$/;
|
|
expect(regex.test(key)).toBe(true);
|
|
});
|
|
|
|
test('returns a string', () => {
|
|
const result = generateRndKey();
|
|
expect(typeof result).toBe('string');
|
|
});
|
|
|
|
test('should generate a key of length between 8 and 192 characters', () => {
|
|
const key = generateRndKey();
|
|
expect(key.length).toBeGreaterThanOrEqual(8);
|
|
expect(key.length).toBeLessThanOrEqual(192);
|
|
});
|
|
|
|
test('should generate a unique key on each invocation', () => {
|
|
const key1 = generateRndKey();
|
|
const key2 = generateRndKey();
|
|
expect(key1).not.toBe(key2);
|
|
});
|
|
});
|