@@ -23,6 +23,7 @@ import {
23
23
screen ,
24
24
type RenderFn ,
25
25
} from '../../../../util/test-utils.js' ;
26
+ import { CircuitError } from '../../../../util/errors.js' ;
26
27
27
28
import { SecondaryLinks , type SecondaryLinksProps } from './SecondaryLinks.js' ;
28
29
@@ -34,7 +35,7 @@ describe('SecondaryLinks', () => {
34
35
return renderFn ( < SecondaryLinks { ...props } /> ) ;
35
36
}
36
37
37
- const baseProps = {
38
+ const baseProps : SecondaryLinksProps = {
38
39
secondaryGroups : [
39
40
{
40
41
secondaryLinks : [
@@ -54,6 +55,7 @@ describe('SecondaryLinks', () => {
54
55
href : '/shop/socks' ,
55
56
onClick : vi . fn ( ) ,
56
57
isActive : true ,
58
+ tier : { variant : 'plus' } ,
57
59
} ,
58
60
] ,
59
61
} ,
@@ -99,6 +101,43 @@ describe('SecondaryLinks', () => {
99
101
expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ;
100
102
} ) ;
101
103
104
+ it ( 'should show a badge when the badge prop is passed' , ( ) => {
105
+ renderSecondaryLinks ( render , baseProps ) ;
106
+ expect ( screen . getByText ( 'New' ) ) . toBeVisible ( ) ;
107
+ } ) ;
108
+
109
+ it ( 'should show a tier indicator when the tier prop is passed' , ( ) => {
110
+ renderSecondaryLinks ( render , baseProps ) ;
111
+ expect ( screen . getByText ( 'plus' ) ) . toBeVisible ( ) ;
112
+ } ) ;
113
+
114
+ it ( 'should throw an error if passed both badge and tier props' , ( ) => {
115
+ const invalidProps : SecondaryLinksProps = {
116
+ secondaryGroups : [
117
+ {
118
+ secondaryLinks : [
119
+ {
120
+ label : 'Shirts' ,
121
+ href : '/shop/shirts' ,
122
+ onClick : vi . fn ( ) ,
123
+ badge : { } ,
124
+ tier : { variant : 'plus' } ,
125
+ } ,
126
+ ] ,
127
+ } ,
128
+ ] ,
129
+ } ;
130
+
131
+ const expectedError = new CircuitError (
132
+ 'SideNavigation' ,
133
+ 'The `badge` and `tier` props cannot be used simultaneously.' ,
134
+ ) ;
135
+
136
+ expect ( ( ) => renderSecondaryLinks ( render , invalidProps ) ) . toThrow (
137
+ expectedError ,
138
+ ) ;
139
+ } ) ;
140
+
102
141
it ( 'should have no accessibility violations' , async ( ) => {
103
142
const { container } = renderSecondaryLinks ( render , baseProps ) ;
104
143
const actual = await axe ( container ) ;
0 commit comments