File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,57 @@ describe('streakParamsSchema user validation', () => {
6262} ) ;
6363
6464describe ( 'streakParamsSchema' , ( ) => {
65+ it ( 'accepts commits mode' , ( ) => {
66+ const result = streakParamsSchema . safeParse ( {
67+ user : 'octocat' ,
68+ mode : 'commits' ,
69+ } ) ;
70+
71+ expect ( result . success ) . toBe ( true ) ;
72+
73+ if ( result . success ) {
74+ expect ( result . data . mode ) . toBe ( 'commits' ) ;
75+ }
76+ } ) ;
77+
78+ it ( 'accepts loc mode' , ( ) => {
79+ const result = streakParamsSchema . safeParse ( {
80+ user : 'octocat' ,
81+ mode : 'loc' ,
82+ } ) ;
83+
84+ expect ( result . success ) . toBe ( true ) ;
85+
86+ if ( result . success ) {
87+ expect ( result . data . mode ) . toBe ( 'loc' ) ;
88+ }
89+ } ) ;
90+
91+ it ( 'falls back to commits for unknown mode' , ( ) => {
92+ const result = streakParamsSchema . safeParse ( {
93+ user : 'octocat' ,
94+ mode : 'unknown' ,
95+ } ) ;
96+
97+ expect ( result . success ) . toBe ( true ) ;
98+
99+ if ( result . success ) {
100+ expect ( result . data . mode ) . toBe ( 'commits' ) ;
101+ }
102+ } ) ;
103+
104+ it ( 'defaults to commits when mode is omitted' , ( ) => {
105+ const result = streakParamsSchema . safeParse ( {
106+ user : 'octocat' ,
107+ } ) ;
108+
109+ expect ( result . success ) . toBe ( true ) ;
110+
111+ if ( result . success ) {
112+ expect ( result . data . mode ) . toBe ( 'commits' ) ;
113+ }
114+ } ) ;
115+
65116 it ( 'accepts a valid width value' , ( ) => {
66117 const result = streakParamsSchema . safeParse ( {
67118 user : 'octocat' ,
You can’t perform that action at this time.
0 commit comments