File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 11import { describe , it , expect } from "vitest" ;
22import { RequirementCollector } from "./RequirementCollector" ;
3- import { parseValueToken } from "src/utils/valueSyntax" ;
3+ import { buildValueVariableKey } from "src/utils/valueSyntax" ;
44
55// Light stubs for app/plugin
66const makeApp = ( ) => ( {
@@ -37,10 +37,13 @@ describe("RequirementCollector", () => {
3737
3838 expect ( byId [ "title" ] . label ) . toBe ( "title" ) ;
3939 expect ( byId [ "title" ] . description ) . toBe ( "Snake cased name" ) ;
40- const parsed = parseValueToken ( multiToken ) ;
41- expect ( parsed ) . not . toBeNull ( ) ;
42- expect ( byId [ parsed ! . variableKey ] . label ) . toBe ( "Priority" ) ;
43- expect ( byId [ parsed ! . variableKey ] . type ) . toBe ( "dropdown" ) ;
40+ const variableKey = buildValueVariableKey (
41+ "low,medium,high" ,
42+ "Priority" ,
43+ true ,
44+ ) ;
45+ expect ( byId [ variableKey ] . label ) . toBe ( "Priority" ) ;
46+ expect ( byId [ variableKey ] . type ) . toBe ( "dropdown" ) ;
4447 } ) ;
4548
4649 it ( "collects VDATE with format and default" , async ( ) => {
Original file line number Diff line number Diff line change @@ -14,6 +14,16 @@ export type ParsedValueToken = {
1414 hasOptions : boolean ;
1515} ;
1616
17+ export function buildValueVariableKey (
18+ variableName : string ,
19+ label : string | undefined ,
20+ hasOptions : boolean ,
21+ ) : string {
22+ return hasOptions && label
23+ ? `${ variableName } ${ VALUE_LABEL_KEY_DELIMITER } ${ label } `
24+ : variableName ;
25+ }
26+
1727type ParsedOptions = {
1828 label ?: string ;
1929 defaultValue : string ;
@@ -125,10 +135,7 @@ export function parseValueToken(raw: string): ParsedValueToken | null {
125135 defaultValue = allowCustomInput ? "" : legacyDefault ;
126136 }
127137
128- const variableKey =
129- hasOptions && label
130- ? `${ variablePart } ${ VALUE_LABEL_KEY_DELIMITER } ${ label } `
131- : variablePart ;
138+ const variableKey = buildValueVariableKey ( variablePart , label , hasOptions ) ;
132139
133140 return {
134141 raw,
You can’t perform that action at this time.
0 commit comments