-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtemplate_test.go
More file actions
61 lines (54 loc) · 1.2 KB
/
template_test.go
File metadata and controls
61 lines (54 loc) · 1.2 KB
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
package docsite
import (
"github.com/google/go-cmp/cmp"
"testing"
)
func TestPatchTempalteForSEO(t *testing.T) {
tt := []struct {
name string
content string
want string
}{
{
name: "content without robots meta is patched",
content: `
{{define "seo"}}
<meta property="og:locale" content="en_EN">
<!-- Always set a title -->
{{ if .Content }}
`,
want: `
{{define "seo"}}
<meta property="og:locale" content="en_EN">
<meta name="robots" content="noindex,nofollow">
<!-- Always set a title -->
{{ if .Content }}
`,
},
{
name: "content with robots meta is not patched",
content: `
{{define "seo"}}
<meta property="og:locale" content="en_EN">
<meta name="robots" content="noindex,nofollow">
<!-- Always set a title -->
{{ if .Content }}
`,
want: `
{{define "seo"}}
<meta property="og:locale" content="en_EN">
<meta name="robots" content="noindex,nofollow">
<!-- Always set a title -->
{{ if .Content }}
`,
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
got := string(patchTemplateForSEO([]byte(tc.content)))
if diff := cmp.Diff(tc.want, got); diff != "" {
t.Errorf("want and got mismatch (-want, +got): %s", diff)
}
})
}
}