|
| 1 | +import React from 'react'; |
| 2 | +import { shallow, mount } from 'enzyme'; |
| 3 | +import { Masthead, MastheadBrand, MastheadContent, MastheadMain, MastheadToggle } from '../index'; |
| 4 | + |
| 5 | +describe('Masthead', () => { |
| 6 | + test('verify basic', () => { |
| 7 | + const view = shallow(<Masthead>test</Masthead>); |
| 8 | + |
| 9 | + expect(view).toMatchSnapshot(); |
| 10 | + }); |
| 11 | + |
| 12 | + test('verify full structure', () => { |
| 13 | + const view = mount( |
| 14 | + <Masthead> |
| 15 | + <MastheadToggle>Toggle</MastheadToggle> |
| 16 | + <MastheadMain> |
| 17 | + <MastheadBrand>Logo</MastheadBrand> |
| 18 | + </MastheadMain> |
| 19 | + <MastheadContent> |
| 20 | + <span>Content</span> |
| 21 | + </MastheadContent> |
| 22 | + </Masthead> |
| 23 | + ); |
| 24 | + |
| 25 | + expect(view).toMatchSnapshot(); |
| 26 | + }); |
| 27 | + |
| 28 | + test('verify custom class', () => { |
| 29 | + const view = mount(<Masthead className="custom-css">test</Masthead>); |
| 30 | + |
| 31 | + expect(view).toMatchSnapshot(); |
| 32 | + }); |
| 33 | + |
| 34 | + test('verify inline display breakpoints', () => { |
| 35 | + const view = mount( |
| 36 | + <Masthead |
| 37 | + display={{ default: 'inline', sm: 'inline', md: 'inline', lg: 'inline', xl: 'inline', '2xl': 'inline' }} |
| 38 | + > |
| 39 | + test |
| 40 | + </Masthead> |
| 41 | + ); |
| 42 | + |
| 43 | + expect(view).toMatchSnapshot(); |
| 44 | + }); |
| 45 | + |
| 46 | + test('verify stack display breakpoints', () => { |
| 47 | + const view = mount( |
| 48 | + <Masthead display={{ default: 'stack', sm: 'stack', md: 'stack', lg: 'stack', xl: 'stack', '2xl': 'stack' }}> |
| 49 | + test |
| 50 | + </Masthead> |
| 51 | + ); |
| 52 | + |
| 53 | + expect(view).toMatchSnapshot(); |
| 54 | + }); |
| 55 | + |
| 56 | + Object.values(['insetNone', 'insetXs', 'insetSm', 'insetMd', 'insetLg', 'insetXl', 'inset2xl', 'inset3xl'] as [ |
| 57 | + 'insetNone', |
| 58 | + 'insetXs', |
| 59 | + 'insetSm', |
| 60 | + 'insetMd', |
| 61 | + 'insetLg', |
| 62 | + 'insetXl', |
| 63 | + 'inset2xl', |
| 64 | + 'inset3xl' |
| 65 | + ]).forEach(inset => { |
| 66 | + test(`verify ${inset} inset breakpoints`, () => { |
| 67 | + const view = mount( |
| 68 | + <Masthead inset={{ default: inset, sm: inset, md: inset, lg: inset, xl: inset, '2xl': inset }}>test</Masthead> |
| 69 | + ); |
| 70 | + expect(view).toMatchSnapshot(); |
| 71 | + }); |
| 72 | + }); |
| 73 | +}); |
| 74 | + |
| 75 | +describe('MastheadBrand', () => { |
| 76 | + test('verify basic', () => { |
| 77 | + const view = shallow(<MastheadBrand>test</MastheadBrand>); |
| 78 | + |
| 79 | + expect(view).toMatchSnapshot(); |
| 80 | + }); |
| 81 | + |
| 82 | + test('verify custom class', () => { |
| 83 | + const view = mount(<MastheadBrand className="custom-css">test</MastheadBrand>); |
| 84 | + |
| 85 | + expect(view).toMatchSnapshot(); |
| 86 | + }); |
| 87 | + |
| 88 | + test('verify custom component', () => { |
| 89 | + const view = mount(<MastheadBrand component="div">test</MastheadBrand>); |
| 90 | + |
| 91 | + expect(view).toMatchSnapshot(); |
| 92 | + }); |
| 93 | +}); |
| 94 | + |
| 95 | +describe('MastheadContent', () => { |
| 96 | + test('verify basic', () => { |
| 97 | + const view = shallow(<MastheadContent>test</MastheadContent>); |
| 98 | + |
| 99 | + expect(view).toMatchSnapshot(); |
| 100 | + }); |
| 101 | + |
| 102 | + test('verify custom class', () => { |
| 103 | + const view = mount(<MastheadContent className="custom-css">test</MastheadContent>); |
| 104 | + |
| 105 | + expect(view).toMatchSnapshot(); |
| 106 | + }); |
| 107 | +}); |
| 108 | + |
| 109 | +describe('MastheadMain', () => { |
| 110 | + test('verify basic', () => { |
| 111 | + const view = shallow(<MastheadMain>test</MastheadMain>); |
| 112 | + |
| 113 | + expect(view).toMatchSnapshot(); |
| 114 | + }); |
| 115 | + |
| 116 | + test('verify custom class', () => { |
| 117 | + const view = mount(<MastheadMain className="custom-css">test</MastheadMain>); |
| 118 | + |
| 119 | + expect(view).toMatchSnapshot(); |
| 120 | + }); |
| 121 | +}); |
| 122 | + |
| 123 | +describe('MastheadToggle', () => { |
| 124 | + test('verify basic', () => { |
| 125 | + const view = shallow(<MastheadToggle>test</MastheadToggle>); |
| 126 | + |
| 127 | + expect(view).toMatchSnapshot(); |
| 128 | + }); |
| 129 | + |
| 130 | + test('verify custom class', () => { |
| 131 | + const view = mount(<MastheadToggle className="custom-css">test</MastheadToggle>); |
| 132 | + |
| 133 | + expect(view).toMatchSnapshot(); |
| 134 | + }); |
| 135 | +}); |
0 commit comments