|
| 1 | +/* |
| 2 | + * Copyright (c) 2016-present, Parse, LLC |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * This source code is licensed under the license found in the LICENSE file in |
| 6 | + * the root directory of this source tree. |
| 7 | + */ |
| 8 | +jest.dontMock('../../components/BrowserCell/BrowserCell.react'); |
| 9 | + |
| 10 | +import React from 'react'; |
| 11 | +import renderer from 'react-test-renderer'; |
| 12 | +const BrowserCell = require('../../components/BrowserCell/BrowserCell.react').default; |
| 13 | + |
| 14 | +describe('BrowserCell', () => { |
| 15 | + |
| 16 | + describe('Required fields', () => { |
| 17 | + |
| 18 | + it('should not highlight 0 value', () => { |
| 19 | + const component = renderer.create( |
| 20 | + <BrowserCell value={0} markRequiredField={true} isRequired={true}/> |
| 21 | + ).toJSON(); |
| 22 | + expect(component.props.className).not.toContain('required'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should not highlight false value', () => { |
| 26 | + const component = renderer.create( |
| 27 | + <BrowserCell value={false} markRequiredField={true} isRequired={true}/> |
| 28 | + ).toJSON(); |
| 29 | + expect(component.props.className).not.toContain('required'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should not highlight empty string value', () => { |
| 33 | + const component = renderer.create( |
| 34 | + <BrowserCell value="" markRequiredField={true} isRequired={true}/> |
| 35 | + ).toJSON(); |
| 36 | + expect(component.props.className).not.toContain('required'); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should highlight null value', () => { |
| 40 | + const component = renderer.create( |
| 41 | + <BrowserCell value={null} markRequiredField={true} isRequired={true}/> |
| 42 | + ).toJSON(); |
| 43 | + expect(component.props.className).toContain('required'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should highlight undefined value', () => { |
| 47 | + const component = renderer.create( |
| 48 | + <BrowserCell markRequiredField={true} isRequired={true}/> |
| 49 | + ).toJSON(); |
| 50 | + expect(component.props.className).toContain('required'); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments