daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import Button from './Button';
  4.  
  5. let props;
  6.  
  7. beforeEach(() => {
  8.   props = {
  9.     isPrimary: false,
  10.     isDanger: false,
  11.     isSuccess: false,
  12.   };
  13. });
  14.  
  15. describe('test Button component', () => {
  16.   it.each`
  17.     propName       | propValue | className       | result
  18.     ${'isPrimary'} | ${true}   | ${'is-primary'} | ${true}
  19.     ${'isDanger'}  | ${true}   | ${'is-danger'}  | ${true}
  20.     ${'isSuccess'} | ${true}   | ${'is-success'} | ${true}
  21.   `('should have class $className when prop $propName is equal to $propValue', ({propName, propValue, className, result}) => {
  22.     props = { ...props, [propName]: propValue };
  23.     const enzymeWrapper = shallow(<Button {...props} />);
  24.  
  25.     expect(enzymeWrapper.hasClass(className)).toEqual(result);
  26.   });
  27.  
  28.   it.each`
  29.   propName       | propValue | className       | result
  30.   ${'isPrimary'} | ${false}  | ${'is-primary'} | ${false}
  31.   ${'isDanger'}  | ${false}  | ${'is-danger'}  | ${false}
  32.   ${'isSuccess'} | ${false}  | ${'is-success'} | ${false}
  33. `('should have not class $className when prop $propName is equal to $propValue', ({propName, propValue, className, result}) => {
  34.   props = { ...props, [propName]: propValue };
  35.   const enzymeWrapper = shallow(<Button {...props} />);
  36.  
  37.   expect(enzymeWrapper.hasClass(className)).toEqual(result);
  38. });
  39. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top