@@ -5,9 +5,10 @@ import { Meta, StoryObj } from '@storybook/react-vite';
55
66import { Tabs } from './Tabs' ;
77import { Tab , Tabs as TabsType } from './Tabs.types' ;
8+ import { getVariantIcon } from 'src/atoms/utils' ;
89
910import { PartialStoryFn } from 'storybook/internal/types' ;
10- import { expect , fn , userEvent } from 'storybook/test' ;
11+ import { expect , fn , userEvent , within } from 'storybook/test' ;
1112
1213const OPTIONS : [ Tab < number > , Tab < number > , Tab < number > ] = [
1314 {
@@ -114,6 +115,84 @@ export const WithLeadingIcon: Story = {
114115 } ,
115116 ] ,
116117 } ,
118+ play : async ( { canvas, args } ) => {
119+ for ( const item of args . options ) {
120+ const tabElement = canvas . getByRole ( 'tab' , { name : item . label } ) ;
121+ const icon = within ( tabElement ) . getByTestId ( 'eds-icon-path' ) ;
122+ await expect ( icon ) . toBeInTheDocument ( ) ;
123+ await expect ( icon ) . toHaveAttribute (
124+ 'd' ,
125+ item . leadingIcon ?. svgPathData as string
126+ ) ;
127+ }
128+ } ,
129+ } ;
130+
131+ export const WithTrailingIcon : Story = {
132+ args : {
133+ options : [
134+ {
135+ value : 1 ,
136+ trailingIcon : car ,
137+ label : 'トヨタ' ,
138+ } ,
139+ {
140+ value : 2 ,
141+ trailingIcon : gamepad ,
142+ label : '任天堂' ,
143+ } ,
144+ {
145+ value : 3 ,
146+ trailingIcon : motorcycle ,
147+ label : 'ヤマハ' ,
148+ } ,
149+ ] ,
150+ } ,
151+ play : async ( { canvas, args } ) => {
152+ for ( const item of args . options ) {
153+ const tabElement = canvas . getByRole ( 'tab' , { name : item . label } ) ;
154+ const icon = within ( tabElement ) . getByTestId ( 'eds-icon-path' ) ;
155+ await expect ( icon ) . toBeInTheDocument ( ) ;
156+ await expect ( icon ) . toHaveAttribute (
157+ 'd' ,
158+ item . trailingIcon ?. svgPathData as string
159+ ) ;
160+ }
161+ } ,
162+ } ;
163+
164+ export const Variants : Story = {
165+ args : {
166+ options : [
167+ {
168+ value : 1 ,
169+ variant : 'error' ,
170+ label : 'トヨタ' ,
171+ } ,
172+ {
173+ value : 2 ,
174+ variant : 'warning' ,
175+ label : '任天堂' ,
176+ } ,
177+ {
178+ value : 3 ,
179+ leadingIcon : motorcycle ,
180+ label : 'ヤマハ' ,
181+ } ,
182+ ] ,
183+ } ,
184+ play : async ( { canvas, args } ) => {
185+ const errorTab = canvas . getByRole ( 'tab' , { name : args . options [ 0 ] . label } ) ;
186+ await expect ( within ( errorTab ) . getByTestId ( 'eds-icon-path' ) ) . toHaveAttribute (
187+ 'd' ,
188+ getVariantIcon ( 'error' ) . svgPathData as string
189+ ) ;
190+
191+ const warningTab = canvas . getByRole ( 'tab' , { name : args . options [ 1 ] . label } ) ;
192+ await expect (
193+ within ( warningTab ) . getByTestId ( 'eds-icon-path' )
194+ ) . toHaveAttribute ( 'd' , getVariantIcon ( 'warning' ) . svgPathData as string ) ;
195+ } ,
117196} ;
118197
119198export const WithCount : Story = {
0 commit comments