File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from "vite-plus/test" ;
2+ import { formatProviderSkillDisplayName } from "./inlineSkills.ts" ;
3+
4+ describe ( "formatProviderSkillDisplayName" , ( ) => {
5+ it . each ( [
6+ [ "mca_lab_status" , "mca_lab_status" ] ,
7+ [ "frontend-design:frontend-design" , "frontend-design:frontend-design" ] ,
8+ [ "superpowers:brainstorming" , "superpowers:brainstorming" ] ,
9+ [ "DesignSync" , "DesignSync" ] ,
10+ ] ) ( "shows %s as its skill name when the provider sets no display name" , ( name , label ) => {
11+ expect ( formatProviderSkillDisplayName ( { name } ) ) . toBe ( label ) ;
12+ } ) ;
13+
14+ it ( "prefers the provider display name" , ( ) => {
15+ expect ( formatProviderSkillDisplayName ( { name : "gh-fix-ci" , displayName : " Fix CI " } ) ) . toBe (
16+ "Fix CI" ,
17+ ) ;
18+ } ) ;
19+ } ) ;
Original file line number Diff line number Diff line change @@ -2,23 +2,10 @@ import type { ServerProviderSkill } from "@t3tools/contracts";
22
33export type InlineSkill = Pick < ServerProviderSkill , "name" | "displayName" > ;
44
5- function titleCaseWords ( value : string ) : string {
6- const words : string [ ] = [ ] ;
7- for ( const segment of value . split ( / [ \s : _ - ] + / ) ) {
8- if ( segment . length === 0 ) continue ;
9- words . push ( segment . charAt ( 0 ) . toUpperCase ( ) + segment . slice ( 1 ) ) ;
10- }
11- return words . join ( " " ) ;
12- }
13-
145export function formatProviderSkillDisplayName (
156 skill : Pick < ServerProviderSkill , "name" | "displayName" > ,
167) : string {
17- const displayName = skill . displayName ?. trim ( ) ;
18- if ( displayName ) {
19- return displayName ;
20- }
21- return titleCaseWords ( skill . name ) ;
8+ return skill . displayName ?. trim ( ) || skill . name ;
229}
2310
2411const SKILL_TOKEN_REGEX =
You can’t perform that action at this time.
0 commit comments