forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
at master 1.3 kB view raw
1package markup_test 2 3import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "tangled.org/core/appview/models" 8 "tangled.org/core/appview/pages/markup" 9) 10 11func TestMarkupParsing(t *testing.T) { 12 tests := []struct { 13 name string 14 source string 15 wantHandles []string 16 wantRefLinks []models.ReferenceLink 17 }{ 18 { 19 name: "normal link", 20 source: `[link](http://127.0.0.1:3000/alice.pds.tngl.boltless.dev/coolproj/issues/1)`, 21 wantHandles: make([]string, 0), 22 wantRefLinks: []models.ReferenceLink{ 23 {Handle: "alice.pds.tngl.boltless.dev", Repo: "coolproj", Kind: models.RefKindIssue, SubjectId: 1, CommentId: nil}, 24 }, 25 }, 26 { 27 name: "commonmark style autolink", 28 source: `<http://127.0.0.1:3000/alice.pds.tngl.boltless.dev/coolproj/issues/1>`, 29 wantHandles: make([]string, 0), 30 wantRefLinks: []models.ReferenceLink{ 31 {Handle: "alice.pds.tngl.boltless.dev", Repo: "coolproj", Kind: models.RefKindIssue, SubjectId: 1, CommentId: nil}, 32 }, 33 }, 34 } 35 for _, tt := range tests { 36 t.Run(tt.name, func(t *testing.T) { 37 handles, refLinks := markup.FindReferences("http://127.0.0.1:3000", tt.source) 38 assert.ElementsMatch(t, tt.wantHandles, handles) 39 assert.ElementsMatch(t, tt.wantRefLinks, refLinks) 40 }) 41 } 42}