mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
@@ -91,6 +91,47 @@ func TestGetFormatByExt(t *testing.T) {
|
||||
require.False(t, found)
|
||||
}
|
||||
|
||||
func TestGetFormatByFilename(t *testing.T) {
|
||||
noExtNoDelimMediaType := media.TextType
|
||||
noExtNoDelimMediaType.Suffix = ""
|
||||
noExtNoDelimMediaType.Delimiter = ""
|
||||
|
||||
noExtMediaType := media.TextType
|
||||
noExtMediaType.Suffix = ""
|
||||
|
||||
var (
|
||||
noExtDelimFormat = Format{
|
||||
Name: "NEM",
|
||||
MediaType: noExtNoDelimMediaType,
|
||||
BaseName: "_redirects",
|
||||
}
|
||||
noExt = Format{
|
||||
Name: "NEX",
|
||||
MediaType: noExtMediaType,
|
||||
BaseName: "next",
|
||||
}
|
||||
)
|
||||
|
||||
formats := Formats{AMPFormat, HTMLFormat, noExtDelimFormat, noExt, CalendarFormat}
|
||||
f, found := formats.FromFilename("my.amp.html")
|
||||
require.True(t, found)
|
||||
require.Equal(t, AMPFormat, f)
|
||||
f, found = formats.FromFilename("my.ics")
|
||||
require.True(t, found)
|
||||
f, found = formats.FromFilename("my.html")
|
||||
require.True(t, found)
|
||||
require.Equal(t, HTMLFormat, f)
|
||||
f, found = formats.FromFilename("my.nem")
|
||||
require.True(t, found)
|
||||
require.Equal(t, noExtDelimFormat, f)
|
||||
f, found = formats.FromFilename("my.nex")
|
||||
require.True(t, found)
|
||||
require.Equal(t, noExt, f)
|
||||
f, found = formats.FromFilename("my.css")
|
||||
require.False(t, found)
|
||||
|
||||
}
|
||||
|
||||
func TestDecodeFormats(t *testing.T) {
|
||||
|
||||
mediaTypes := media.Types{media.JSONType, media.XMLType}
|
||||
|
Reference in New Issue
Block a user