All files / src/domain/testClass index.js

100% Statements 7/7
50% Branches 1/2
50% Functions 1/2
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17        2x   2x 2x 2x 2x 1x       2x    
import invariant from 'invariant';
import classnames from 'classnames';
import Config from 'domain/Config';
 
const TEST_REGEXP = /^[a-z][0-9a-z-_]*$/i;
 
let _testClass = () => {};
Eif (Config.get('enableTestClasses') === true) {
  _testClass = (name) => {
    invariant(TEST_REGEXP.test(name), 'Test classes must start with a letter and contain only a-z, 0-9, _ and -.');
    return classnames(`test-${name}`);
  };
}
 
export const testClass = _testClass;
export default testClass;