All files / src/components/Button type.js

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22        4x                       66x 40x   2x    
import styles from './style.postcss';
 
import classnames from 'classnames';
 
export const Type = {
  default: classnames(styles.Button, styles.__default),
  defaultInverse: classnames(styles.Button, styles.__default, styles.__inverse),
  primary: classnames(styles.Button, styles.__primary),
  primaryInverse: classnames(styles.Button, styles.__primary, styles.__inverse),
  correct: classnames(styles.Button, styles.__correct),
  wrong: classnames(styles.Button, styles.__wrong),
  needsAttention: classnames(styles.Button, styles.__needsAttention),
  black: classnames(styles.Button, styles.__black),
};
 
export function validateType(type) {
  if (Object.keys(Type).some((k) => Type[k] === type)) {
    return true;
  }
  throw new Error(`Type "${type}" is not valid! Use the Type object provided`);
}