adding tests for generateRndKey (#2932)

changing jest.config.js
transform option  from -
transform: { '^.+\\.ts?$': 'ts-jest' },
to
  transform: {   '^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }], },
This commit is contained in:
Dev Gupta
2023-04-18 04:03:30 +05:30
committed by GitHub
parent d68b70b850
commit 1a63880d01
3 changed files with 30 additions and 5 deletions

View File

@@ -34,12 +34,11 @@ const saveKeys = async (keys, setError) => {
setError(error);
}
};
const generateRndKey = () => {
export const generateRndKey = () => {
let defaultKey = '';
let isValidStreamKey = false;
const streamKeyRegex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#$%^&*]).{8,192}$/;
const s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*';
const streamKeyRegex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#$^&*]).{8,192}$/;
const s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$^&*';
while (!isValidStreamKey) {
const temp = Array.apply(20, Array(30))