RandomGeneratorUtils.spec.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { assert } from 'chai';
  2. import { RandomGeneratorUtils } from '../../../../src/utils/RandomGeneratorUtils';
  3. describe('RandomGeneratorUtils', () => {
  4. describe('getRandomVariableName (length: number = 6): string', () => {
  5. let randomVariableName: string,
  6. regExp: RegExp;
  7. describe('variant #1: string with random variable of length `4`', () => {
  8. before(() => {
  9. randomVariableName = RandomGeneratorUtils.getRandomVariableName(4);
  10. regExp = /^_0x(\w){4}$/;
  11. });
  12. it('should return random variable name', () => {
  13. assert.match(randomVariableName, regExp);
  14. })
  15. });
  16. describe('variant #2: string with random variable of length `6`', () => {
  17. before(() => {
  18. randomVariableName = RandomGeneratorUtils.getRandomVariableName(6);
  19. regExp = /^_0x(\w){4,6}$/;
  20. });
  21. it('should return random variable name', () => {
  22. assert.match(randomVariableName, regExp);
  23. })
  24. });
  25. });
  26. });