@@ -73,25 +73,26 @@ func TestRenderPathToComponent(t *testing.T) {
7373 })
7474}
7575
76- func TestFormatNode (t * testing.T ) {
77- t .Run ("Empty String should also return an empty string back" , func (t * testing.T ) {
76+ func TestBeautifyPURL (t * testing.T ) {
77+ t .Run ("empty String should also return an empty string back" , func (t * testing.T ) {
7878 inputString := ""
79- result := integrations .BeautifyPURL (inputString )
79+ result , _ := integrations .BeautifyPURL (inputString )
8080 assert .Equal (t , "" , result )
8181 })
82- t .Run ("Should change nothing when there are less than 2 slashes in the input string " , func (t * testing.T ) {
83- inputString := "StringWIthOnlyOne/ "
84- result := integrations .BeautifyPURL (inputString )
82+ t .Run ("invalid purl format should also be returned unchanged " , func (t * testing.T ) {
83+ inputString := "this is definitely not a valid purl "
84+ result , _ := integrations .BeautifyPURL (inputString )
8585 assert .Equal (t , inputString , result )
8686 })
87- t .Run ("Should put a line break behind the second slash " , func (t * testing.T ) {
88- inputString := "StringWIthOnlyOne// "
89- result := integrations .BeautifyPURL (inputString )
90- assert .Equal (t , "StringWIthOnlyOne// \n " , result )
87+ t .Run ("should return only the namespace and the name of a valid purl and cut the rest " , func (t * testing.T ) {
88+ inputString := "pkg:npm/@ory/integrations@v0.0.1 "
89+ result , _ := integrations .BeautifyPURL (inputString )
90+ assert .Equal (t , "@ory/integrations " , result )
9191 })
92- t .Run ("Should put a line break behind every second slash " , func (t * testing.T ) {
93- inputString := "StringWIthOnlyOne//moreText/newText/nowTHefinalTextChallenge// "
94- result := integrations .BeautifyPURL (inputString )
95- assert .Equal (t , "StringWIthOnlyOne// \n moreText/newText/ \n nowTHefinalTextChallenge// \n " , result )
92+ t .Run ("should return no leading slash if the namespace is empty " , func (t * testing.T ) {
93+ inputString := "pkg:npm/integrations@v0.0.1 "
94+ result , _ := integrations .BeautifyPURL (inputString )
95+ assert .Equal (t , "integrations " , result )
9696 })
97+
9798}
0 commit comments