forked from gobuffalo/tags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc_test.go
41 lines (35 loc) · 1.1 KB
/
misc_test.go
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
package tags
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_StylesheetTag(t *testing.T) {
r := require.New(t)
tcases := []struct {
Options Options
Expected string
}{
{Options: Options{"href": "styles.css"}, Expected: `<link href="styles.css" rel="stylesheet" />`},
{Options: Options{}, Expected: `<link rel="stylesheet" />`},
{Options: Options{"style": "text/scss"}, Expected: `<link rel="stylesheet" style="text/scss" />`},
}
for _, tcase := range tcases {
tag := StylesheetTag(tcase.Options)
r.Equal(tcase.Expected, tag.String())
}
}
func Test_JavascriptTag(t *testing.T) {
r := require.New(t)
tcases := []struct {
Options Options
Expected string
}{
{Options: Options{"src": "script.js"}, Expected: `<script src="script.js"></script>`},
{Options: Options{"src": "script.js", "body": `alert("hello")`}, Expected: `<script src="script.js"></script>`},
{Options: Options{"body": `alert("hello")`}, Expected: `<script>alert("hello")</script>`},
}
for _, tcase := range tcases {
tag := JavascriptTag(tcase.Options)
r.Equal(tcase.Expected, tag.String())
}
}