@@ -6,18 +6,18 @@ import { DropdownButton } from "./dropdown-button";
66import { render } from "@testing-library/react" ;
77
88describe ( "DropdownButton" , ( ) => {
9+ const menuItems = [
10+ { component : faker . random . word ( ) , onSelect : ( ) => { } } ,
11+ { component : faker . random . word ( ) , onSelect : ( ) => { } } ,
12+ ] ;
13+
914 test ( "when default props, renders Dropdown Button" , ( ) => {
1015 // Arrange
1116 const expected = faker . random . words ( ) ;
12- const itemOne = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
13- const itemTwo = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
1417
1518 // Act
1619 const { getByText } = render (
17- < DropdownButton
18- buttonContents = { expected }
19- menuItems = { [ itemOne , itemTwo ] }
20- />
20+ < DropdownButton buttonContents = { expected } menuItems = { menuItems } />
2121 ) ;
2222
2323 // Assert
@@ -26,8 +26,6 @@ describe("DropdownButton", () => {
2626
2727 test ( "when buttonClassName prop provided, renders with class name" , ( ) => {
2828 // Arrange
29- const itemOne = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
30- const itemTwo = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
3129 const testButtonContents = faker . random . words ( ) ;
3230 const testButtonClassName = "testButtonClassName" ;
3331
@@ -36,7 +34,7 @@ describe("DropdownButton", () => {
3634 < DropdownButton
3735 buttonClassName = { testButtonClassName }
3836 buttonContents = { testButtonContents }
39- menuItems = { [ itemOne , itemTwo ] }
37+ menuItems = { menuItems }
4038 />
4139 ) ;
4240 const result = container . getElementsByClassName ( testButtonClassName ) ;
@@ -47,16 +45,14 @@ describe("DropdownButton", () => {
4745
4846 test ( "when button size prop provided, renders with correct size class" , ( ) => {
4947 // Arrange
50- const itemOne = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
51- const itemTwo = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
5248 const testButtonContents = faker . random . words ( ) ;
5349 const testButtonSize = ButtonSizes . Large ;
5450
5551 // Act
5652 const { container } = render (
5753 < DropdownButton
5854 buttonContents = { testButtonContents }
59- menuItems = { [ itemOne , itemTwo ] }
55+ menuItems = { menuItems }
6056 size = { testButtonSize }
6157 />
6258 ) ;
@@ -68,16 +64,14 @@ describe("DropdownButton", () => {
6864
6965 test ( "when button style prop provided, renders with correct style class" , ( ) => {
7066 // Arrange
71- const itemOne = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
72- const itemTwo = { component : faker . random . word ( ) , onSelect : ( ) => { } } ;
7367 const testButtonContents = faker . random . words ( ) ;
7468 const testButtonStyle = ButtonStyles . Destructive ;
7569
7670 // Act
7771 const { container } = render (
7872 < DropdownButton
7973 buttonContents = { testButtonContents }
80- menuItems = { [ itemOne , itemTwo ] }
74+ menuItems = { menuItems }
8175 style = { testButtonStyle }
8276 />
8377 ) ;
0 commit comments