File: description_test.go

package info (click to toggle)
dh-make-golang 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 344 kB
  • sloc: makefile: 12; sh: 9
file content (112 lines) | stat: -rw-r--r-- 4,519 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package main

import (
	"strings"
	"testing"
)

func TestReformatForControl(t *testing.T) {
	content := `
There are a few options for using a custom style:                       
                                                                        
 1. Call glamour.Render(inputText, "desiredStyle")                      
 2. Set the GLAMOUR_STYLE environment variable to your desired default  
 style or a file location for a style and call                          
 glamour.RenderWithEnvironmentConfig(inputText)                         
 3. Set the GLAMOUR_STYLE environment variable and pass                 
 glamour.WithEnvironmentConfig() to your custom renderer                
                                                                        
Check out these projects, which use glamour:                            
                                                                        
 * Glow (https://github.com/charmbracelet/glow), a markdown renderer for
 the command-line.                                                      
 * GitHub CLI (https://github.com/cli/cli), GitHub’s official command   
 line tool.                                                             
 * GLab (https://github.com/profclems/glab), An open source GitLab      
 command line tool.                                                     
`

	want := ` There are a few options for using a custom style:
 .
  1. Call glamour.Render(inputText, "desiredStyle")
  2. Set the GLAMOUR_STYLE environment variable to your desired default
     style or a file location for a style and call
     glamour.RenderWithEnvironmentConfig(inputText)
  3. Set the GLAMOUR_STYLE environment variable and pass
     glamour.WithEnvironmentConfig() to your custom renderer
 .
 Check out these projects, which use glamour:
 .
  * Glow (https://github.com/charmbracelet/glow), a markdown renderer for
    the command-line.
  * GitHub CLI (https://github.com/cli/cli), GitHub’s official command
    line tool.
  * GLab (https://github.com/profclems/glab), An open source GitLab
    command line tool.
`

	got := reformatForControl(content)
	if got != want {
		t.Errorf("\nwant\n====\n%v\ngot\n===\n%v", want, got)
	}
}

func TestMarkdownToLongDescription(t *testing.T) {
	content := `
## Styles

You can find all available default styles in our [gallery](https://github.com/charmbracelet/glamour/tree/master/styles/gallery).
Want to create your own style? [Learn how!](https://github.com/charmbracelet/glamour/tree/master/styles)

There are a few options for using a custom style:
1. Call §glamour.Render(inputText, "desiredStyle")§
1. Set the §GLAMOUR_STYLE§ environment variable to your desired default style or a file location for a style and call §glamour.RenderWithEnvironmentConfig(inputText)§
1. Set the §GLAMOUR_STYLE§ environment variable and pass §glamour.WithEnvironmentConfig()§ to your custom renderer


## Glamourous Projects

Check out these projects, which use §glamour§:
- [Glow](https://github.com/charmbracelet/glow), a markdown renderer for
the command-line.
- [GitHub CLI](https://github.com/cli/cli), GitHub’s official command line tool.
- [GLab](https://github.com/profclems/glab), An open source GitLab command line tool.
`
	content = strings.Replace(content, "§", "`", -1)

	want := ` Styles
 .
 You can find all available default styles in our gallery
 (https://github.com/charmbracelet/glamour/tree/master/styles/gallery).
 Want to create your own style? Learn how!
 (https://github.com/charmbracelet/glamour/tree/master/styles)
 .
 There are a few options for using a custom style:
 .
  1. Call glamour.Render(inputText, "desiredStyle")
  2. Set the GLAMOUR_STYLE environment variable to your desired default
     style or a file location for a style and call glamour.
     RenderWithEnvironmentConfig(inputText)
  3. Set the GLAMOUR_STYLE environment variable and pass glamour.
     WithEnvironmentConfig() to your custom renderer
 .
 Glamourous Projects
 .
 Check out these projects, which use glamour:
 .
  * Glow (https://github.com/charmbracelet/glow), a markdown renderer for
    the command-line.
  * GitHub CLI (https://github.com/cli/cli), GitHub’s official command
    line tool.
  * GLab (https://github.com/profclems/glab), An open source GitLab
    command line tool.
`

	got, err := markdownToLongDescription(content)
	if err != nil {
		t.Errorf("markdownToLongDescription failed: %v", err)
	}
	if got != want {
		t.Errorf("\nwant\n====\n%v\ngot\n===\n%v", want, got)
	}
}