@@ -117,4 +117,40 @@ describe('findForUrl', () => {
117117 expect ( loadedPlugins [ 1 ] . default ) . toHaveBeenCalledTimes ( 0 )
118118 } )
119119 } )
120+
121+ describe ( 'axe finding categorization' , ( ) => {
122+ function axeViolation ( tags : string [ ] ) {
123+ return {
124+ id : 'some-rule' ,
125+ help : 'Help' ,
126+ helpUrl : 'https://example.com' ,
127+ description : 'Description' ,
128+ tags,
129+ nodes : [ { html : '<div></div>' , failureSummary : 'summary' } ] ,
130+ }
131+ }
132+
133+ async function categoryFor ( tags : string [ ] ) {
134+ clearAll ( )
135+ actionInput = JSON . stringify ( [ 'axe' ] )
136+ vi . mocked ( AxeBuilder . prototype . analyze ) . mockResolvedValueOnce ( {
137+ violations : [ axeViolation ( tags ) ] ,
138+ } as unknown as axe . AxeResults )
139+
140+ const findings = await findForUrl ( 'test.com' )
141+ return findings [ 0 ] . category
142+ }
143+
144+ it ( 'categorizes a violation with only wcag tags as wcag' , async ( ) => {
145+ expect ( await categoryFor ( [ 'wcag2a' , 'wcag111' ] ) ) . toBe ( 'wcag' )
146+ } )
147+
148+ it ( 'categorizes a violation with a best-practice tag as best-practice' , async ( ) => {
149+ expect ( await categoryFor ( [ 'cat.semantics' , 'best-practice' ] ) ) . toBe ( 'best-practice' )
150+ } )
151+
152+ it ( 'categorizes a violation with an experimental tag as experimental, even alongside wcag tags' , async ( ) => {
153+ expect ( await categoryFor ( [ 'wcag2a' , 'experimental' ] ) ) . toBe ( 'experimental' )
154+ } )
155+ } )
120156} )
0 commit comments